Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts

    html,body vs body

    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?

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    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?
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts
    overflow...
    Last edited by resin; 06-04-2012 at 12:49 PM.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    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.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #5
    Regular Coder
    Join Date
    Nov 2011
    Posts
    154
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I wanted overflow to work with onload. Look here- scrollbar appear after page load?

    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?

  • #6
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    945
    Thanks
    0
    Thanked 129 Times in 128 Posts
    <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.
    Last edited by Lerura; 06-04-2012 at 06:53 PM.


  •  

    Posting Permissions

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