Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display property overridden by User Agent Stylesheet

Tags:

css

As must be obvious, I am no CSS expert. I have a class

.hidden{
 display:hidden
}

and a div

<div class="hidden">
</div>

But the div is not hidden when the page is rendered. When I look at the Computed styles in Chrome, it says the display property was overridden by the user agent stylesheet. Why?

like image 751
septerr Avatar asked Dec 20 '25 04:12

septerr


2 Answers

Css:

.hidden {    
    display: none
}

is the correct syntax.

like image 75
Andrea Turri Avatar answered Dec 24 '25 11:12

Andrea Turri


If you want the element to not be visible AND not take in any space you should do:

.hidden { display: none; }

However if you want to hide the element, but let it take in space you should do:

.hidden { visibility: hidden; }

See this simple demo for an example.

The fact that you think the style is overwritten by the user-agent is that the user-agent doesn't recognize the style you are trying to use (because it is invalid).

like image 27
PeeHaa Avatar answered Dec 24 '25 12:12

PeeHaa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!