Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens with display:initial on non CSS3 browsers?

I need to know what value/ css would be set when I use display: initial on non CSS3 compliant browsers ?

I'm hiding the class using display:none & need to show back, for which I intend to use display: initial (I dont want to use display:block if previously it was display:inline) but the hidden element must be shown on all browsers.

like image 531
Rajat Gupta Avatar asked Mar 24 '23 08:03

Rajat Gupta


2 Answers

What happens by CSS 2.1 rules on error handling as well as in practice is that the declaration display: initial is ignored, without affecting the rest of the style sheet. The display property thus gets its value from other rules. In the absence of any setting on it in any style sheet (including browser default style sheet), the initial value inline is used.

The “fallback” code in the edit of your question means that the value of display would be inline in browsers that support the value inline, and block in other browsers. This does not sound safe.

The value initial does not mean “the previous value set in a style sheet” or anything like that, as the question seems to postulate. Instead, it means the value that is designated as the property’s initial value in CSS specifications. For display, this is inline.

like image 134
Jukka K. Korpela Avatar answered Mar 31 '23 07:03

Jukka K. Korpela


Ok, I found that providing a fallback would be a safer option. So I use like below:

{
display: block;// just as fallback
display: initial;
}
like image 25
Rajat Gupta Avatar answered Mar 31 '23 08:03

Rajat Gupta