user1184100
user1184100

Reputation: 6894

Why is html>body used?

I came across html>body in one of the stylesheets and wanted to know as to why it is used.

html>body {
  font-size: 16px; 
  font-size: 78.75%;
}

Upvotes: 1

Views: 107

Answers (4)

Michael Zaporozhets
Michael Zaporozhets

Reputation: 24566

the '>' means that it is referencing on child elements of the parent (in this case 'html')

so for example I could have an arrangement of divs that look like so

<div id="outermost">
  <div class="inner">
     <div class="inner">
     </div>
  </div>
</div>

and i wrote some css like so

#outermost>.inner { background-color: #CCC; }

it would only apply the rules to the first level '#inner'

Obviously there is only one body tag however it used to be a hack to exclude ie6 and below to write different rules for ie7+ ;)

Upvotes: 2

Sreevisakh
Sreevisakh

Reputation: 1926

'> symbol indicates child of Above code means The style applies to all the tag body which is a child of html

    #sample>div

above applies to all divs which are children of the element with id sample

Upvotes: 1

ToddBFisher
ToddBFisher

Reputation: 11610

Child selector, more info here: http://www.w3.org/TR/CSS2/selector.html#child-selectors

So in your code it would be any body child of html

Upvotes: 1

Marko
Marko

Reputation: 72230

It's called a Child Selector.

The reason it's being used is likely because it's a hack to exclude IE6 and below. Those browsers don't understand the > selector.

More Information

Upvotes: 3

Related Questions