Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Practical Pages

Default browser styles

What the browser's built-in stylesheet does to headings, paragraphs, lists, links, tables and form controls, how to see it in DevTools, and how to override it.

Before any of your CSS runs, every page already has styles. Each browser carries a built-in user-agent stylesheet that makes a bare <h1> big and bold, puts space around paragraphs, indents lists and draws links in blue. Your stylesheet is applied on top of it, and because author styles beat user-agent styles in the cascade, any rule you write wins.

Knowing the defaults explains many "why is there space here?" mysteries. The values below are the common ones; exact numbers can vary slightly between browsers, so treat them as a guide and inspect your own browser when precision matters.

CSS
/* A simplified taste of a user-agent stylesheet */
body { margin: 8px; }
h1 { font-size: 2em; font-weight: bold; margin-block: 0.67em; }
p { margin-block: 1em; }
ul { padding-inline-start: 40px; }

Try it

Plain, unstyled HTML. Everything you see comes from the browser, none from us. Notice the outer gap, heading sizes, list indentation and the quote's side margins.

Nothing but defaults

Common defaults

Element Typical default
body margin: 8px
h1 to h6 Bold, sizes about 2em, 1.5em, 1.17em, 1em, 0.83em, 0.67em, with vertical margins
p, ul, ol, dl About 1em of top and bottom margin
ul, ol About 40px of inline-start padding; bullets or numbers
blockquote About 1em vertical and 40px horizontal margin
a Colored and underlined; a different color once visited
strong, b, th Bold (th is also centered)
em, i, cite Italic
mark Yellow-ish background with dark text
small, sub, sup Smaller text; sub and sup also shift the baseline
code, pre, kbd, samp Monospace font; pre keeps line breaks
hr A thin inset rule with margins
table Small border-spacing between cells
Buttons and form controls Native look, their own font size, and no inherited font family
img, span, a, em display: inline
div, p, section, ul, h1 display: block

Seeing and overriding them

  • DevTools. In the Styles pane, rules labelled user agent stylesheet come from the browser. They are listed at the bottom because they have the lowest priority.
  • Override with any rule. Even a single type selector such as p { margin: 0 } beats the defaults, regardless of specificity, because of the cascade origin.
  • Undo your own changes with revert, which rolls a property back to the browser default, or all: revert to do it for every property.
  • Reset by choice. A reset or normalize sheet replaces many defaults in one place.

Usage notes

  • Do not assume 16px everywhere. The root font size is the user's preference (commonly 16px), which is why rem units respect settings and px does not.
  • Form controls do not inherit fonts. Add font: inherit on button, input, select, textarea to match the page.
  • Heading sizes are not semantics. Choose h1 to h6 by structure, then size them with CSS.
  • Default margins collapse. Adjacent vertical margins of paragraphs combine instead of adding, which is part of why the spacing between them is 1em and not 2em.
  • Dark mode and colors. The default text color and background follow the color-scheme and the user's system settings; see color-scheme.
  • Different engines, small differences. Never rely on a default for pixel-exact layout; set the value you need.

Browser support

Every browser has a user-agent stylesheet, and the common defaults follow the HTML Standard's rendering section, so differences are small and mostly in form controls.