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 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Does the body tag have infinite height and length?

    Does the body tag have infinite height and width?

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Nope. The canvas, or the drawing area, has infinite size in all directions. In ie6w quirks mode or ie5w this corresponds to the body element, but in modern browsers in in ie6w standards mode it corresponds to the html element. In XML it corresponds to the root element, whichever element that is.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    HTML - canvas = <body>
    XHTML - canvas = <html>

    You can test by saving the following "Hello World!" example as (something).html and resaving as (something.xhtml). Open in Firefox or another Gecko browser and compare.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>Hello World!</title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
    <style type="text/css">
    
    body {
    background-color: #f0f;
    }
    
    </style>
    </head>
    <body>
    <div>
      <h1>Hello World!</h1>
    </div>
    </body>
    </html>
    Have fun, and feel free to prove me wrong!

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    No. According to css, the root element (which in HTML is the html element) corresponds to the canvas. The fact that backgrounds set on the body tag propagate up to the canvas is a quirk in CSS made especially to allow for one of the mistakes of the HTML specification.
    From [CSS2.1] 14.2 The background:
    The background of the root element becomes the background of the canvas and covers the entire canvas, anchored at the same point as it would be if it was painted only for the root element itself. The root element does not paint this background again.

    For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. User agents should observe the following precedence rules to fill in the background of the canvas of HTML documents: if the value of the 'background' property for the HTML element is different from 'transparent' then use it, else use the value of the 'background' property for the BODY element. If the resulting value is 'transparent', the rendering is undefined. This does not apply to XHTML documents.
    Try applying a different background colour to the html and body element to see what I'm talking about.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, I guess you are right.

    So, if you give the <html> element a background color, it encompasses the entire page since it is the canvas. If you don't specify a background-color for the <html> element, then, the <body> becomes the canvas (at least in Firefox 0.93 and IE6). This is for HTML, hence the .html file extension.

    If you repeated same test above with Firefox, but made it XHTML, hence the .xhtml file extension, the <html> element is always the canvas. You can't test this in IE since doesn't support XHTML properly.

    Perhaps Mozilla should remove the .xhtml file extension, and use .html or .htm and detect the DOCTYPE... But that slows down the browser...


  •  

    Posting Permissions

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