Introducing The Css Cascade

User Agent Style Sheets: Basics andSamples

Post from September 22, 2007 (↻ May 27, 2021), filed under Web Development.This và many other posts are also available as a pretty, well-behaved ebook: On Web Development.

Bạn đang xem: Introducing the css cascade

CSS takes care of the mặc định formatting of documents through the concept of user agent style sheets, 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.


Figure: HTML document with Firefox defaultstyling.


CSS1 introduces the idea by stating that “each User Agent (UA, often a ‘website browser’ or ‘web client’) will have a default style sheet that presents documents in a reasonable—but arguably mundane—manner.” CSS2 says that “conforming user agents must apply a default style sheet (or behave sầu as if they did)” và 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.” CSS3 is of the same mind.

Since the CSS specifications leave it up to implementations whether khổng lồ use a “real” style sheet for mặc định display or not, it’s not surprising that you don’t find a mặc định style sheet in every browser’s installation thư mục. Unlượt thích Microsoft’s Internet Explorer as well as Opera, for example, Gecko browsers lượt thích Firefox and Netscape Navigator (“html.css”) but also Konqueror make it rather simple lớn comprehend their default styles.

Example User Agent StyleSheets

The following is a danh mục of default style sheets I’ve compiled over recent years (except for Safari; thank you, Martin). Due khổng lồ 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 mặc định style sheets proposed by the W3C in the specifications of CSS1, CSS2, CSS2.1, & CSS2.2:

User Agent & Reset StyleSheets

The examples alặng to provide some insight inkhổng lồ user agent style sheets. Knowledge of user agent style sheets should help get a better understanding of CSS as well as any display “phenomemãng cầu.”

However, I encourage to use this knowledge for other things than building more or larger “reset” style sheets. Assuming use of additional style sheets other than just a reset, reset style sheets are typically unnecessary. From my experience, the only occasionally helpful & then quite memorable remix is * margin: 0; padding: 0; . Reset style sheets are going lớn be handled in other posts though, revealing why they’re, well, bad.

About Me


I’m Jens Oliver, and I’m an engineering manager và author. I love sầu trying things, sometimes including philosophy, art, & adventure. Here on I nội dung some of my views andexperiences.If you have sầu questions or suggestions about what I write, please leave sầu a phản hồi (if available) or amessage.

Comments (Closed)

On September 22, 2007, 12:15 CEST, Alen said:Thanks for sharing this. You said it well, it gives us better understanding of css & how/what to lớn bởi vì with our own style sheets.

Xem thêm: Tải Revit 2017 Full Crack + Hướng Dẫn Crack Revit 2017 Thành Công 100%

On September 24, 2007, 8:37 CEST, Martin Hassman said:For Safari/Webkit stylesheets cannot be found in the installation (propably compiled inkhổng lồ some library), but they are on the website source tracking system with their history


On September 24, 2007, 11:18 CEST, Jens Oliver said:Thanks Martin—I updated the post.

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 rephối 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.

On September 26, 2007, 9:54 CEST, Daniel said:I absolutely don’t agree with you. The rephối with * margin: 0; padding: 0; is the worst method of resetting the browser’s mặc định styles.Especially when working on khung elements it make a lot of problems.

The better reset: Rephối Reloaded

Kind regardsDaniel

On November 12, 2007, 19:50 CET, Lynne said:Interesting read… I just assumed that if the liên kết khổng lồ the CSS was broken the browsers would default lớn plain HTML formatting. However, it certainly makes more sense khổng lồ have sầu a default css tệp tin.

On December 30, 2007, 23:34 CET, Lazar said:Thanks for this. It’s really useful info! Especially for CSS beginners lượt thích me.

On January 7, 2008, 15:53 CET, Anders said:Interesting read, but I am not able khổng lồ find out where a textarea’s mặc định fonts (courier) comes from. Anybody?

On February 14, 2008, 22:22 CET, ty said:Thanks for an excellent writeup.So what vì you start with as a mặc định then?I’ve been using a reset of sorts, và am finding some of those defining things I never use in my markup, so that seems redundant to lớn me.How to lớn be sure borders, margins don’t create problems without resetting them or defining them khổng lồ be the same despite whatever UA styling could derail a layout?

On April 28, 2011, 20:37 CEST, John Lascurettes said:I would love sầu khổng lồ know how lớn pry inkhổng lồ IE’s resource files khổng lồ view the actual UA CSS the way I can with Gecko & Webkit. Does anyone have sầu a guide on how to lớn bởi vì that? The googles has failed me.

Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations và definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Google Play Books, andLeanpub.