Webmaster Tips & Tricks Newsletter

April 5, 2004.

Welcome to the award winning Bravenet Tips and Tricks Newsletter, loaded with tips, scripts and other webmaster tricks from the developers at Bravenet.com.
Featured in this Issue...

  Visit the Tips and Tricks Archive



Staff Member Image
The Body Tag -- Deprecated Attributes
by Roger Riche

As you all know, the standard structure of a webpage includes the <BODY> tag, which opens the body of your webpage document. The body of your HTML document contains all information that is presentable to the user as opposed to it's predecessor, the <HEAD> tag. Here's the standard structure:

<html>
<head>
<title>Your Webpage</title>
</head>
<body>
Your Content
</body>
</html>

A deprecated element or attribute of html means that the element or attribute has been tagged to be removed from future versions of the html language but is still accessible for backwards compatibility. It is strongly advised to not use any tag or attribute that is deprecated.

The body tag contains several deprecated attributes that people are still guilty of using and should veer away from. The following is a list of deprecated BODY tag attributes:

  • link: Used to specify the color of your page links.
  • vlink: Sets the visited link color.
  • alink: Sets the active link color.
  • bgcolor: Sets the page's background color.
  • text: Sets the default color of your body text.

Here is an example of an HTML tag using deprecated attributes. Avoid using the attributes in the example:

<body alink="red" vlink="maroon" link="blue" text="black" bgcolor="white" background="title.jpg">

Above, we've set the style for common webpage elements. You can achieve the same thing properly by using CSS. In the <head> of your HTML document, place this style sheet:

<style type="text/css">
body
{
color: black;
background-color: white;
background-image: url('title.jpg');
}
a
{
color: blue;
}
a:visited
{
color: maroon;
}
a:active
{
color: red;
}
</style>

With the above style in the HEAD of your document, your BODY tag should now look like: <body> -- no more attributes.

That's it! You have converted your html to use proper html by removing the deprecated attributes in your body tag. There are many other deprecated attributes that have CSS alternative. We will touch base on in another issue of our Tips and Tricks Newsletter. In the meantime, check out some of these useful sites about cascading style sheets:

Happy coding!





 
Featured Stories Inside Today's Newsletter:

Divs And Spans   |  The Body Tag - Deprecated Attributes   |  Commenting Your HTML Documents