SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot biggie2's Avatar
    Join Date
    Feb 2006
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why use html>body ?

    What exactly is the logic when people use html>body or html>body #div ?

    I see this quite often but never understood it.

  2. #2
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Older browsers like IE6 ignore html>body, it's a way to fix browser specific CSS problems.

  3. #3
    SitePoint Zealot c.t.c.'s Avatar
    Join Date
    Apr 2007
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, html>body is a CSS child selector. Many developers use this as a CSS filter.

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,281
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    As mentioned above the child selector when used on html>body is used as a filter for Ie6 (and under) because they don't understand it.

    It makes no difference to other browsers because body is always a direct child of html anyway and therefore will always be true whether you used the combinator or not.

    When you use the child selector on other elements then it has a specific purpose to only pick out elements that are a direct child.

    e.g.

    div>ul

    The above would not target any uls that are nested in a parent ul unlike a descendant selector (div ul) which would target all uls within the div. The child selctor only targets uls that are a direct child of the div and not its grandchildren.

    More info here.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •