AvailabilityDOM Level 1 HTML Inherits from/OverridesNode Element HTMLElement HTMLBodyElement Properties
DescriptionThe HTMLBodyElement interface represents the <body> tag of a document. All HTML documents have a <body> tag, even if it does not explicitly appear in the document source. You can obtain the HTMLBodyElement of a document through the body property of the HTMLDocument interface. The properties of this object specify default colors and images for the document. Although these properties represent the values of <body> attributes, the Level 0 DOM made these same values accessible through properties (with different names) of the Document object. See the Document object in the client-side reference section of this book for details. Although these color and image properties belong more appropriately to the HTMLBodyElement interface than they do to the Document object, note that they are all deprecated because the HTML 4 standard deprecates the <body> attributes that they represent. The preferred way to specify colors and images for a document is using CSS styles. Exampledocument.body.text = "#ff0000"; // Display text in bright red document.fgColor = "#ff0000"; // Same thing using old DOM Level 0 API document.body.style.color = "#ff0000"; // Same thing using CSS styles See AlsoDocument object in the client-side reference section |