Forum Moderators: not2easy

Message Too Old, No Replies

Why use html>body ?

         

AffiliateDreamer

6:23 pm on Feb 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

What exactly does this mean:

html>body

How is it different from just using?

body

SuzyUK

9:22 pm on Feb 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it is a legitimate selector, but was/is mainly used as a hack,

it is a child selector [w3.org]. Of course <body> is always the child element of the <html> element so it should mean it's unnecessary to state that, however..

MSIE never understood child selectors until IE7 so it was used primarily in hiding hacks from IE, that is if you wanted to target an element for everything but IE you would preface your rules with that.. IE ignored them because it didn't understand - however now that IE7 reads them.. you are right there is (possibly) no need whatsoever for it.

BUT! if you are seeing them in your code they were/are likely there for a reason so test in IE6 as well as 7

-Suzy

penders

9:32 pm on Feb 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The ">" is the 'child selector'. So this selects the body element which is a direct child of the html element. Yes, this is always true! However, IE5.5 and IE6 on Windows do not support the child selector (>), so to me this looks like a browser hack(?) This rule excludes IE5.5 and IE6, whereas simply using '
body
' will include all browsers.

html>body
is also more specific [webmasterworld.com], but I don't think that really matters in this instance?

<edit>*snap*!</edit>

AffiliateDreamer

5:17 pm on Feb 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



is there a list of all CSS hacks? or is it just trial and error? (just in case someone compiled them all in one place)

Achernar

5:35 pm on Feb 19, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



This page [centricle.com...] , shows a table of available hacks and targeted browsers.

SuzyUK

6:14 pm on Feb 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well there are some sources.. CssHack [css-discuss.incutio.com] being the one attached to Eric Meyers "CSS-discuss" mailing list and (I can't believe this one..) there is a book! [webmasterworld.com]

however there are many undocumented ways to apply filters - loopholes that didn't quite reach the "main sites" so don't rely on them for all.

However the fact that you are asking "Why Use.." means you don't need links like these IMHO ;) - hacks and filters are old news, if you see something weird (like

* html
or
html>body
or
_rule
) in your stylesheet (btw, all of these "filters" are still predominant in freely downloadable templates code) then you already know it's out of the ordinary and in that case I personally would move as quickly as possible to lose the rule and go the Conditional Comments [webmasterworld.com] route in order to take care of IE's CSS foibles instead.

good luck
-Suzy

Wlauzon

5:58 pm on Feb 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agree with Suzy on this (of course I do, she is the Universal Guru of CSS...).

Just for grins I was looking at the code a couple days ago for some site templates that are marketed as being compliant with the universe.

A few of them still had old IE5 hacks in them.