View Full Version : Does the body tag have infinite height and length?

10-04-2004, 07:44 AM
Does the body tag have infinite height and width?

10-04-2004, 01:34 PM
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.

10-04-2004, 05:18 PM
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.

<!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">
<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;

<h1>Hello World!</h1>

Have fun, and feel free to prove me wrong!

10-04-2004, 07:04 PM
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 (http://www.w3.org/TR/CSS21/colors.html#q2):
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.

10-04-2004, 07:50 PM
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...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum