...

View Full Version : html,body vs body



resin
06-03-2012, 05:24 PM
In the past I used html,body{} in my css, instead of just body{}. But recently I realized that I would need to change it to body (remove html) in order for some javascript code to work. So I was wondering what the difference is between html,body and body? Am I sacrificing anything by removing html?

Excavator
06-03-2012, 06:06 PM
Hello resin,
html, body just targets both elements. Using body alone targets only the body of the document.

What was in html, body {} that was disabling your js?

resin
06-03-2012, 06:18 PM
overflow...

Excavator
06-03-2012, 07:32 PM
I guess I don't know why you want to control overflow with js. I think CSS handles overflow just fine but if you're going to do it with js then it should probably be removed from your CSS to avoid conflicts like you are experiencing.
Kind of hard to say for sure without knowing what you're doing.

resin
06-04-2012, 01:55 PM
I wanted overflow to work with onload. Look here- http://www.codingforums.com/showthread.php?t=263351

And I'll go ahead and ask what I had asked there.. Why is the body tag needed at all? Forgive if I'm mistaken, but the html tag can carry all the styling that body does, no? Therefore the body acts just as any other div, basically a child div of html, right? So why the need for both html and body?

Lerura
06-04-2012, 07:47 PM
<html> is the container for the entire document. while <body> is the container for only the elements to display on the page.
and <head> is the container for information about the document and possible modifiers like css and script.

but you are somewhat right!
These 3 tags can seem as just some extra coding.

But then again: Why do a car have a trunk, when you can just as well throw your stuff on the backseat?
And why do it have seats, if you can sit on the floor.

Everything in the document have it's purpose, even if some of it might look like just extra coding.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum