p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 (http://p2p.wrox.com/book-beginning-css-cascading-style-sheets-web-design-isbn-978-0-7645-7642-3-154/)
-   -   HTML tag vs Body Tag (http://p2p.wrox.com/book-beginning-css-cascading-style-sheets-web-design-isbn-978-0-7645-7642-3/34087-html-tag-vs-body-tag.html)

CFGerry October 7th, 2005 07:04 AM

HTML tag vs Body Tag
 
Hi -

I'm a bit confused about creating styles that affect the outermost "wrapper" of your web page. On page 124 of the book, the HTML tag is given the style definition that causes the thick black frame around the page content. (This is done through use of the :root pseudo-class, but I'm guessing that the effect would be the same if I just referenced the HTML tag in the style definition). I would have thought that the body tag would have been the tag to reference to get this effect. (In fact, there might have been an example in the book where the body tag was used.) I think of the HTML tag as unrelated to web page display. Is there a difference between using body vs html tag? If so, can anyone tell me what?


richard.york October 7th, 2005 07:13 AM

I can't think of any differences. You have to reference the <html> tag on occaision though. For instance, if you want to set the height of the <body> element to 100% of the viewport, the <html> tag must also be set to 100%. That has to do with the shrink-to-fit height sizing algorithm specified in the CSS standards.

The :root psuedo-class isn't very useful in HTML because you *can* reference the <html> tag directly. Where it becomes useful, and the reason for it existing as far as I can tell, is in XML where the root element can be variable, and not always the same tag.

Hope that answers your question.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design


All times are GMT -4. The time now is 01:46 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.