Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is *html selector really needed?

Tags:

html

css

I just read this code somewhere.

*html #menu ul{margin: 0px 0px 0px 40px;width:960px;}

I know * means the selector means any element in css. But is this needed here? Since it works totally the same without it.Or is it some kind of CSS hacks in specific browsers ?

like image 919
Johnny Chen Avatar asked May 23 '14 06:05

Johnny Chen


1 Answers

It is a CSS hack targeted at Internet Explorer 6 and below. More modern browsers should ignore any of the styles applied using *html.

List of browsers which will apply the styles

  • IE4-6/Win
  • IE4-5/Mac
  • IE7+, when in backwards compatibility mode (aka quirks mode)

List of browsers which will ignore the styles

  • IE7+, when in Standards Compatibility mode
  • Firefox
  • NS6.0-7.2
  • NS4.x
  • Opera 5+ (I don't know about versions 1 through 4.)
  • Safari
  • Konqueror 3
  • iCab 3

Source: * html ("Star HTML") CSS Hack

So, provided your document is valid then IE7+ should display the page in standards mode and will ignore the styles. If the page is being displayed in 'quirks mode' then the styles will be applied in IE7+.

like image 115
Red Taz Avatar answered Oct 25 '22 17:10

Red Taz