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
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:
<style>
body { font-size: 12px; }
</style>
<table>
<tr><td>foo
</table>
bar
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
table { font-size: medium }
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
<!DOCTYPE html>
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:
table { font-size: 100% }
This means that a table gets the font size of its parent. (Like in inheritance, but safer.)
Chrome user agent stylesheet overwriting my site style
Vonkly helped identify the issue. I went digging through all my stylesheets and I found a typo, sort of, in one of them - it was missing the parent element when defining the link style for the header, so instead of
header a:link, header a:visited {
...
}
I had
header a:link, a:visited {
...
}
so it was overriding the style I defined for the links in the body. I must have missed it while reviewing my stylesheets the first time around.
Thanks for your comments, everybody!
Override USER AGENT STYLE SHEET - Chrome
Just add the following style:
ul { padding:0 }
That will override the default style.
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
html {/* globals here*/}
into:
* {/* globals here */}
... 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).
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:
input, input[type="password"], input[type="search"] {
cursor: auto;
}
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
For (1):
<style>
.a, .a input {
cursor: pointer;
}
</style>
For (2):
<style>
input {
cursor: inherit;
}
.a {
cursor: pointer;
}
</style>
Display property overridden by User Agent Stylesheet on Chrome version 25.0.1364.152
This happens if you have the Chrome addon "AdBlock" installed and active.
You can access it in the top right corner of your browser and there temporary inactivate it to see the difference.
As you mentioned try removing "ad" from the class name to avoid AdBlock from hiding the element.
Related Topics
Angular 6 Component Not Showing Up
Error Error: Formcontrolname Must Be Used With a Parent Formgroup Directive
Embed Pdf on a Webpage and Prevent Download
Angular 5, Html, Boolean on Checkbox Is Checked
Moving an Image Across a HTML Canvas
What Does Enctype='Multipart/Form-Data' Mean
One Flex/Grid Item Sets the Size Limit For Siblings
How to Select an Element With Multiple Classes in Jquery
Element Will Not Stay Centered, Especially When Re-Sizing Screen
How to Pass Boolean Variable of False in a Url
Call Method from HTML Only One Time in Angular2
How to Make Div 100% Height of Browser Without Vertical Scrolling of Header
How to Vertically Align Text in Input Type="Text"
How to Put CSS @Media Rules Inline
How to Make Transparent Color White Instead of Black in Html2Canvas
How to Make a Div 100% Height of the Browser Window
Is There a ≪Meta≫ Tag to Turn Off Caching in All Browsers