Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'[hidden]' selectors in css

Tags:

html

css

When we view normalize.css http://necolas.github.io/normalize.css/ source code, we can see the following:

[hidden], template {
    display: none;
}

What is the meaning of [hidden] ?

like image 880
gongeek Avatar asked Sep 01 '25 10:09

gongeek


2 Answers

[attribute] is a selector for elements that have an attribute attribute.

[hidden] matches elements like this <p hidden>Hidden paragraph</p>.

The value doesn't matter, as long as the attribute exists. [lang] matches elements like this for example <p lang="pt-br">Paragráfo</p>.

P.S.: [attribute=value] also works. e.g. [headers="numberHeader"] for matching <td headers="numberHeaders">...</td>

like image 170
OdraEncoded Avatar answered Sep 04 '25 03:09

OdraEncoded


According to a fast google search, I found the following

/*
* Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3,
* and Safari 4.
* Known issue: no IE 6 support.
*/

[hidden] {
display: none;
}

so obviously, you use the "hidden" attribute when you want something not to show up in your (e.g. html) code.

like image 21
Giannis Tzagarakis Avatar answered Sep 04 '25 01:09

Giannis Tzagarakis