How to Stop User Agent Stylesheets from Overriding My CSS
How to stop user agent stylesheets from overriding my css
The «problem» here is that there is actually no input style in the author stylesheet (see the spec for more info), and therefore the style that is defined in the user agent stylesheet is used.
The (relevant) user agent rule (on chrome) is:
You can achieve what you want in a couple ways:
-
Create a css class that selects the input directly, for example
- using another css class, or
- selecting the input within the already-defined class,
- etc
Why is the user agent stylesheet overriding my html<> style?
Nope. If you want your styles to have precedence, they need to apply to the same element. Which, in our case, is input .
You have applied styles to the html element, not to input .
Now, if you changed your selector to html * , to html input , to input or to * , it would be a different story. The two selectors would get compared and yours would have precedence.
The only difference between your selectors and the ones in the default browser stylesheet is yours are loading later, hence, provided you have the same specificity, yours apply. So the minimum selector for yours to apply would be input <> .
But the important bit here is: html <> only styles inheritable input properties which are not defined (not set) at element level. If they are set inheritance does not happen (there’s no need to inherit, because the property resolves). The input set value applies, regardless of values and specificity on any of the parents. In fact, if what you’re expecting would happen, designing web would be a lot more difficult and a lot less flexible (IMHO).
Which is a reaaaaaly long way of saying: change
. and they’ll probably work as intended. But be warned: it will apply to all elements, and you will soon understand why the way inheritance works is, in fact, quite smart (and helpful).
Override User Agent Stylesheet CSS in Chrome Browser
Add ul < list-style-type: none; >in your CSS to override the default style applied by the browser (from the user agent stylesheet) and remove the li bullet points
How to prevent user agent stylesheet from overriding my own CSS?
the dropdown and the input size will match up.
Edit: Usually you can use a css reset such as normalize.css to automatically take care of little quirks like this.
user agent stylesheet override my own styles
The answer to the general question is that only property settings set on an element itself are taken into account when deciding which style setting “wins”. For example, if we have just one style sheet that sets font-size: 18px on the body element and another style sheet that set font-size: 9px on all p elements, then the font size of p elements is 9px, no matter what the origins of the style sheets are, e.g. whether the latter is just a browser default style sheet. Inheritance plays no role here. This is all described in section Assigning property values, Cascading, and Inheritance of the CSS 2.1 spec.
Inheritance is considered only after the above “fight” has been resolved. Only then are inheritable properties inherited by elements that have them not set at all.
The specific question does not provide specific code, but it can be inferred that you have something like this:
Normally this causes both “foo” and “bar” to appear in 12px size. The table cell inherits the size from the table row, which inherits it from the tbody element, which inherits it from the table, which inherits it from the body .
However, in your case, this chain is broken. The reason is that the browser style sheet has
which in practice tends to mean 16px. Now the table element has the property set, so the cell inherits that value.
Browsers do not normally have such a rule in their style sheets. However, in Quirks Mode, most browsers apply the rule. This means that font size is not inherited from body into tables. This reflects bugs (or oddities) in very old versions of IE and lets legacy page be rendered as they used to be.
If you have unintentionally caused Quirks Mode and do not need it for other purposes, just slap
at the very start of your document. But beware that old pages may get messed up in different ways, if they have been designed in testing conditions that correspond to Quirks Mode.
Alternatively, add the following rule into your style sheet:
This means that a table gets the font size of its parent. (Like in inheritance, but safer.)
User agent stylesheet is overriding my css even though it acknowledges it shouldn’t?
Looking at your screenshot of the element’s computed styles, I notice that its float is set to left . Floating an element tends to blockify it, and in the case of a table-row, that does indeed turn it into a block and ultimately detach it from its table container, as a table-row cannot normally be floated. This is not a case of the UA stylesheet overriding your styles, but how the display and float properties interact.
In order for a table layout to work you cannot float any of its internal table elements, including row groups, rows, and cells. (You can float the table itself.) As I am not familiar with your layout I won’t be able to suggest a proper and complete answer to your question, but the key here is to remove the float declaration from that element. Since this declaration doesn’t appear in your own styles it must be elsewhere — look for it among the rest of the element’s styles. If necessary, override it using float: none .
(There may of course be other factors causing this blockification that as others have mentioned require a proper reproduction of your problem to diagnose, but this is what I could glean from just the screenshots you’ve provided and is a very common and likely cause.)
Как отключить user agent stylesheet
Css – chrome : how to turn off user agent stylesheet settings
I am trying to disable the User Agent Stylesheet in chrome. How can I turn this off/disable this?

Best Solution
- Open Chrome dev tools
- Click gear icon on bottom right
- In General section, check or uncheck "Show user agent styles".
Related Solutions
Html – Set cellpadding and cellspacing in CSS
Basics
For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding":
For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing":
This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".
Issues in IE ≤ 7
This will work in almost all popular browsers except for Internet Explorer up through Internet Explorer 7, where you're almost out of luck. I say "almost" because these browsers still support the border-collapse property, which merges the borders of adjoining table cells. If you're trying to eliminate cellspacing (that is, cellspacing="0" ) then border-collapse:collapse should have the same effect: no space between table cells. This support is buggy, though, as it does not override an existing cellspacing HTML attribute on the table element.
In short: for non-Internet Explorer 5-7 browsers, border-spacing handles you. For Internet Explorer, if your situation is just right (you want 0 cellspacing and your table doesn't have it defined already), you can use border-collapse:collapse .
Note: For a great overview of CSS properties that one can apply to tables and for which browsers, see this fantastic Quirksmode page.
Css – How to disable text selection highlighting
UPDATE January, 2017:
According to Can I use, the user-select is currently supported in all browsers except Internet Explorer 9 and its earlier versions (but sadly still needs a vendor prefix).
These are all of the available correct CSS variations:
Note that user-select is in standardization process (currently in a W3C working draft). It is not guaranteed to work everywhere and there might be differences in implementation among browsers. Also, browsers can drop support for it in the future.
The values of this attribute are none , text , toggle , element , elements , all and inherit .
chrome : how to turn off user agent stylesheet settings?
I am trying to disable the User Agent Stylesheet in chrome. How can I turn this off/disable this?

![]()
1 Answer 1
- Open Chrome dev tools
- Click gear icon on bottom right
- In General section, check or uncheck «Show user agent styles».
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.
-
The Overflow Blog
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.5.25.43461
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to stop user agent stylesheets from overriding my css
How to stop user agent stylesheets from overriding my css
I’m trying to set cursor: pointer on a dom element, but the input isn’t taking it (I am not seeing a pointer cursor when I hover over the checkbox). In chrome, I see that the “user agent stylesheet” is overriding my css. Wtf?
I have seen this question: Why does user agent stylesheet override my styles? But my problem does not seem to be the doctype, which is the recommended doctype.
Using !important isn’t acceptable here, and neither is styling the input node directly – I shouldn’t have to worry about weird browser useragent styles. What’s going on?
To clarify, my question is about why the user agent stylesheet is overriding the css and how to make that stop. My question is not how I can hack around this behavior. If I’m not mistaken, the correct behavior of css is that the cursor style should be inherited by child nodes.
Is this the expected behavior of css?
Solution – 1
The “problem” here is that there is actually no input style in the author stylesheet (see the spec for more info), and therefore the style that is defined in the user agent stylesheet is used.
The (relevant) user agent rule (on chrome) is:
You can achieve what you want in a couple ways:
- Create a css class that selects the input directly, for example
- using another css class, or
- selecting the input within the already-defined class,
- etc
- Explicitly setting inheritance behavior for the cursor style on all inputs
Solution – 2
It seems like this might just be css being css, which is unfortunate. The most general workaround I can come up with is to defined this css:
This allows the behavior I originally expected to happen in all cases where the user agent would otherwise cause the style not to inherit. This is better than styling the input with “cursor: pointer” directly because you only have to set this style up once, and any domNodes with a “cursor: pointer” style that contain an input will automatically have the input have a pointer cursor.
Solution – 3
Answering this question generally with elaborating the explanation I would say, the final value of css property is a four step calculation ( ie. specification, computed, used and actual ) according to this post.
In specification, Cascading takes precedence over Inheritance.
Since , you don’t have any css property of input so user agent stylesheet applied to input takes precedence over inherited value from class a. In order to use inherited value you should override using code as suggested by @B T.
ie.
Explanation of Cascading :
I am referring detailed explanation here –
There are three main concepts that control the order in which CSS declarations are applied:
- Importance
- Specificity
- Source order
Importance of a CSS declaration depends on where it is specified. The conflicting declarations will be applied in the following order; later ones will override earlier ones:
- User agent style sheets
- Normal declarations in user style sheets
- Normal declarations in author style sheets
- Important declarations in author style sheets
- Important declarations in user style sheets
specificity and source order is not relevant for this question, you could refer above references for explanation of the same
In above code since you only have user agent style sheet bounded with
the element directly, hence takes precedence.In short inheritance < cascading < importance < user agent stylesheet
is precedence order in your case.
Solution – 4
I thought I had this problem and checked the usual suspects, Doctype, etc. As ridiculous as this sounds, it turned out the style which I thought was being applied was commented out in the CSS. However, Chrome was displaying the style as if it was an actual style and being overridden.
Solution – 5
This behaviour is seen in Chrome only (it is not in Firefox, I didn’t test Edge or others). Chrome applies a pale yellow background ( #E8F0FE )
Today I got the same issue, tested with no such pale-effect on Safari and Brave…
Not sure why the so-long-waiting (3 years and counting) from Chrome to come up with a fix.
Solution – 6
Had this same issue in my Angular app when using Material. Added normalize.css and still had the issue. I added specific css for the element being overridden (or so I thought) by the user agent stylesheet, in the case a button, and where that ‘worked’, it didn’t seem write.
Anyway, the solution in this case was to ensure that I also had imported the Material Button Module. Once I added that, the button rendered as expected.
tl;dr: Include all the necessary modules from angular/material being used by your view.
User agent stylesheet как убрать
When filling the form form, I found a good chrome pit!
When you have filled out the form before and got the focus, the input will have a drop-down list of the text that you filled in before, like this: (sorry for being ugly, privacy issues are mosaic)

It stands to reason that this is no problem. Many times, it is necessary to record the input for convenience, but at the same time, it is also found that the text box has become yellow! And when you select the text, it is still shit yellow!

It’s really a trough. This is not the effect I want at all, who wants to face a sloppy yellow thing! Why is this happening? why? I don’t know, other browsers won’t
How can chrome, which always shows people with a good image, become like this?
Okay, I can only go to Google in Baidu! I am not alone in encountering such a problem!
It turned out that:
Look, not only input, textarea, and select, but also "-webkit"! When you see this, you must think of setting background-color to cover it, so you start to use clever code. After a few seconds of tossing, you will refresh with confidence, you will find. this is not useful. Ah
Regardless of why he wants this, big companies want to do this, can you beat him if you are not convinced? ! Come see the solution!
Because this thing appears only when there is an input record before, only the record of disabling input can be ok! For example: <input type="text" autocomplete="off" >, so that when you click on input, it will not have that list! The whole world will be clean! Of course, if you can tolerate that shit yellow, you can also give it "on", or do not set it, because autocomplet is "on" by default!
However, in many cases, you may need to not allow you to remove simple and convenient records! How can that be done?
-webkit- box-shadow : 0 0 0px 1000px white inset That’s right, it is to set a built-in shadow for input! And it must be larger, at least larger than your input itself! However, box-shadow is very slow! Moreover, if your input uses a picture as the background, there is no way to do so! So in the actual development, how to choose in the end, it has to weigh its own!
In preparation A section of text has been bolded on the website , I looked at the webpage source code and CSS without bold code, reviewed the element is a piece of user agent stylesheet code.