liveBook · Manning

Stylesheet origin

As explained in CSS in Depth, Second Edition

Stylesheet origin is the cascade criterion representing the source category from which a style declaration comes, such as author or browser defaults.

Stylesheet origin is the cascade criterion that identifies where a declaration comes from. Browsers combine author styles, user styles, and user-agent styles when resolving conflicts. section 1.1 section 1.1.1

The three stylesheet origins have different priorities:

  • Author styles are declarations added to the page and normally override browser defaults. section 1.1.1
  • User styles are end-user customizations positioned between user-agent and author styles; they are uncommon and may require browser support or extensions. section 1.1.1
  • User-agent styles are browser defaults, such as heading margins, list padding and bullets, link colors, and default font sizes. section 1.1.1

Replacing browser defaults

A page header initially receives browser-provided list padding, bullets, link colors, and underlines. Author rules can replace those defaults by removing list styling and padding, displaying navigation items inline, and assigning custom link colors, backgrounds, spacing, and decoration. section 1.1.1

Listing 1.3 Overriding user-agent styles
h1 {
  color: #2f4f4f;
  margin-bottom: 10px;     #1
}

#main-nav {
  margin-top: 10px;       #1
  list-style: none;     #2
  padding-left: 0;      #2
}

#main-nav li {
  display: inline-block;    #3
}

#main-nav a {
  color: white;                #4
  background-color: #13a4a4;   #4
  padding: 5px;                #4
  border-radius: 2px;          #4
  text-decoration: none;       #4
}

Inspect the CSS declarations that override user-agent styles on a navigation menu and its links. section 1.1.1

How CSS in Depth, Second Edition covers it

How deep it goes
Distinguishes three origins, describes their priority, and demonstrates overriding browser defaults without detailing their implementation internals.
Examples
Uses browser defaults for headings, lists, and links, then overrides navigation spacing, bullets, colors, backgrounds, and text decoration.
What it assumes
Assumes basic HTML and CSS declarations while teaching browser defaults and cascade origins explicitly.
What you can do after
Evaluate which stylesheet source wins and override unwanted browser defaults with author CSS.
How it connects
Connects stylesheet origin to the cascade, author styles, user styles, user-agent styles, inline styles, specificity, layers, scope, and source order.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.