liveBook · Manning

User-agent style

As explained in CSS in Depth, Second Edition

The rendering defaults supplied by a web browser through its user-agent stylesheet.

User-agent styles are the browser’s built-in rendering defaults. They give headings and paragraphs margins, lists indentation and bullets, and links familiar colors, sizes, and underlines. Author styles override them because they have higher cascade priority. section 1.1.1

Common defaults become visible when a page does not replace them:

  • Headings receive larger font sizes and top and bottom margins. section 1.1.1
  • Unordered lists receive left padding and disc markers. section 1.1.1
  • Links appear blue and underlined unless author styles change them. section 1.1.1

Replacing navigation defaults

A navigation list can become horizontal by removing its padding and markers, displaying items inline-block, and assigning custom link colors, backgrounds, padding, rounded corners, 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 that overrides default heading margins and transforms a bulleted navigation list into styled horizontal links. section 1.1.1

Use revert when author styles should be undone while preserving the browser default, such as restoring a blue, underlined link. More specific declarations can still override revert. section 1.3.4

How CSS in Depth, Second Edition covers it

How deep it goes
Explains stylesheet origins, priority, common defaults, overrides, and revert, without descending into browser implementation internals.
Examples
Uses headings, paragraphs, lists, links, and a styled navigation bar to demonstrate defaults and deliberate overrides.
What it assumes
Assumes basic CSS declarations and selectors while establishing stylesheet origins and cascade priority.
What you can do after
Apply it via CSS by identifying browser defaults, overriding unwanted values, and restoring selected defaults with revert.
How it connects
Connects user-agent styles to author styles, user styles, the CSS cascade, specificity, inheritance, and the revert keyword.

Also explained in

Compare how 3 books explain user-agent style →

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.