HomeĐời SốngModify chrome user agent stylesheet

Modify chrome user agent stylesheet

22:00, 27/03/2021

User Agent Style Sheets: Basics andSamples

Post from September 22, 2007 (↻ February 17, 2021), filed under Web Development. (Tweetthis?)This & many other posts are also available as a pretty, well-behaved ebook: On Web Development.

Bạn đang xem: Modify chrome user agent stylesheet

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 website 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 ‘website client’) will have a mặc định style sheet that presents documents in a reasonable—but arguably mundane—manner.” CSS2 says that “conforming user agents must apply a mặc định style sheet (or behave as if they did)” & that “a user agent’s mặc định 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 sầu it up to lớn 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 like Firefox and Netscape Navigator (“html.css”) but also Konqueror make it rather simple khổng lồ comprehkết thúc their mặc định styles.

Example User Agent StyleSheets

The following is a list of default style sheets I’ve compiled over recent years (except for Safari; thank you, Martin). Due to lớn the fact that Firebird, Firefox, và 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 CSS1, CSS2, CSS2.1, & CSS2.2:

User Agent và Rephối StyleSheets

The examples aim lớn provide some insight inlớn user agent style sheets. Knowledge of user agent style sheets should help get a better understanding of CSS as well as any display “phenomena.”

However, I encourage lớn 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; . Remix style sheets are going to be handled in other posts though, revealing why they’re, well, bad.

About Me


I’m Jens Oliver aiesec-unwe.net, & I’m a website developer (engineering manager) & author. I love trying things, sometimes including philosophy, art, and adventure. Here on aiesec-unwe.net I tóm tắt 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 và how/what to lớn vì chưng with our own style sheets.

Xem thêm: Cách Mặc Áo Dài Đẹp Cho Người Mập, Duyên Dáng Đến Lạ Kì, Bí Quyết Chọn Vải Áo Dài Cho Người Mập

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 website source tracking system with their history


On September 24, 2007, 11:18 CEST, Jens Oliver aiesec-unwe.net 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 sầu 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 lớn 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 remix 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: Remix Reloaded

Kind regardsDaniel

On November 12, 2007, 19:50 CET, Lynne said:Interesting read… I just assumed that if the links lớn the CSS was broken the browsers would default lớn plain HTML formatting. However, it certainly makes more sense lớn have sầu a mặc định 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 default fonts (courier) comes from. Anybody?

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

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

Perhaps my most relevant book: CSS Optimization Basics (2018). Writing CSS is a craft. As craftspeople we strive khổng lồ write high unique CSS. In CSS Optimization Basics I lay out some of the most important aspects of such CSS. Available at Amazon, Google Play Books, andLeanpub.