HTML Fundamentals - The Body Tag
The body tag acts as a container for everything within the body section. It will look something like this:
Assorted HTML code goes here...
As with most HTML tags, you can add attributes that affect how everything within that tag looks. Since the body tag holds all of that page’s visible items, changing the body tag’s attributes will affect the entire page.
Note that all of the body tag attributes are now deprecated! If you want to change your page’s appearance, use CSS; it’s the approved way to format a webpage, and it has a great deal more flexibility and far more options for the website designer. Nonetheless, for a complete understanding of HTML you should be familiar with the body tag’s attributes – for one thing, you might come across a webpage one day that still uses them, and you’ll know how to fix it!
Without further ado, here are the body tag attribute options:
link: Sets the text color for all links throughout the page. You can either use one of the named colors, or specify a shade using hexadecimal code.
alink: Sets the color for active links on the webpage.
vlink: Sets the color for previously visited links.
text: Sets the color for all text on the page.
background: Lists an image file to use as the page’s background.
bgcolor: Specifies the page’s background color.
If you were to use these attributes, the body tag would look something like this:
<body text ="purple" alink="yellow" vlink="red" bgcolor="green" background="image.gif">
Assorted HTML code...
Be careful when setting the background attribute to list the image's file path correctly. If your image is in the same folder as your webpage, all you need to do is list the image name. Otherwise, you need to direct the browser to the proper folder on your server. If you're in doubt, it's best to use an absolute url (which looks something like 'http://www.domain.com/images/image.gif') so that it'll work correctly regardless of where the page is located.
This site needs an editor - click to learn more!
Editor's Picks Articles
Top Ten Articles
Content copyright © 2018 by Elizabeth Connick. All rights reserved.
This content was written by Elizabeth Connick. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.