Jens Meiert

User Agent Style Sheets: Basics and Samples

Jens O. Meiert, September 22, 2007 (↻ August 27, 2014).

This entry has been written by Jens the .

CSS budgets for default formatting of documents by the user agent style sheet concept, a cornerstone of the cascade. It means that a web browser doesn’t just present a line of text when it’s fed with an HTML document that has no styling information attached, but instead serves it using minimal formatting.

Unstyled HTML document.

Figure: HTML document with Firefox default styling.

Specification

CSS 1 introduces the idea by stating that “each User Agent (UA, often a ‘web browser’ or ‘web client’) will have a default style sheet that presents documents in a reasonable—but arguably mundane—manner.” CSS 2 says that “conforming user agents must apply a default style sheet (or behave as if they did)” and that “a user agent’s default style sheet should present the elements of the document language in ways that satisfy general presentation expectations for the document language.” CSS 3 is likely to be of the same mind.

Since the CSS specifications leave it up to implementations whether to use a “real” style sheet for default display or not, it’s not surprising that you don’t find a default style sheet in every browser’s installation folder. Unlike Microsoft’s Internet Explorer as well as Opera, for example, Gecko browsers like Firefox and Netscape Navigator (“html.css”) but also Konqueror make it rather simple to comprehend their default styles.

Example Files

The following is a list of default style sheets I compiled over recent years (except for the Safari example; thank you, Martin). I’ve occasionally looked for and compared user agent style sheets (.css); due to the fact that Firebird, Firefox, and Co. are all based on the same layout engine, they’re quite similar, if not identical.

For comparison, note the exemplary default style sheets proposed by the W3C in the specifications of CSS 1, CSS 2, and CSS 2.1:

User Agent and Reset Style Sheets

This post aims to provide a little more insight into user agent style sheets. Knowledge of user agent style sheets should help getting a better understanding of CSS as well as display “phenomena.”

However, I encourage to use this knowledge for other things than building more or larger “reset” style sheets. Assuming use of other than just reset style sheets, these style sheets are typically unnecessary. From my experience, the only occasionally helpful and then quite memorable reset is * { margin: 0; padding: 0; }. Reset style sheets are handled in another post though, revealing why they’re, well, bad.

Comments (Closed)

  1. On September 22, 2007, 12:15 CEST, Alen said:

    Thanks for sharing this. You said it well, it gives us better understanding of css and how/what to do with our own style sheets.

  2. On September 24, 2007, 8:37 CEST, Martin Hassman said:

    For Safari/Webkit stylesheets cannot be found in the installation (propably compiled into some library), but they are on the web source tracking system with their history

    http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/css/html4.css
    http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/css/quirks.css

  3. On September 24, 2007, 11:18 CEST, Jens O. Meiert said:

    Thanks Martin—I updated the post.

  4. On September 25, 2007, 16:29 CEST, Barney said:

    This is a very nice piece, Jens. I’m glad someone can give this little study authoritatively because the recent craze over reset stylesheets, and inherently the notion that browser defaults are bad, is often very misguided: If you are going to respecify everything, there is no need for the extra rule for every element; if you aren’t, you’re far better off with the user/developer’s consideration than nothing.

  5. On September 26, 2007, 9:54 CEST, Daniel said:

    I absolutely don’t agree with you. The reset with * {margin: 0; padding: 0; } is the worst method of resetting the browser’s default styles.
    Especially when working on form elements it make a lot of problems.

    The better reset: Reset Reloaded

    Kind regards
    Daniel

  6. On November 12, 2007, 19:50 CET, Lynne said:

    Interesting read… I just assumed that if the link to the CSS was broken the browsers would default to plain HTML formatting. However, it certainly makes more sense to have a default css file.

  7. On December 30, 2007, 23:34 CET, Lazar said:

    Thanks for this. It’s really useful info! Especially for CSS beginners like me.

  8. On January 7, 2008, 15:53 CET, Anders said:

    Interesting read, but I am not able to find out where a textarea’s default font (courier) comes from. Anybody?

  9. On February 14, 2008, 22:22 CET, ty said:

    Thanks for an excellent writeup.
    So what do you start with as a default then?
    I’ve been using a reset of sorts, and am finding some of those defining things I never use in my markup, so that seems redundant to me.
    How to be sure borders, margins don’t create problems without resetting them or defining them to be the same despite whatever UA styling could derail a layout?

  10. On February 25, 2008, 11:52 CET, Jens O. Meiert said:

    This post is also available in German.

  11. On April 28, 2011, 20:37 CEST, John Lascurettes said:

    I would love to know how to pry into IE’s resource files to view the actual UA CSS the way I can with Gecko and Webkit. Does anyone have a guide on how to do that? The googles has failed me.

Read More

Have a look at the most popular posts, eventually including:

Found a mistake? Reward! Email me, jens@meiert.com.

You are here: meiert.comArchive for 2007 → User Agent Style Sheets: Basics and Samples

Last update: August 27, 2014.