Skip to: content, navigation

by Ian Lloyd

color (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2
Full Full Full None
Spec
Depr. Version
Yes N/A
color="color"

Example

This code adds a blue horizontal line below the paragraph:

<p>And with that the actress and the bishop made a rather 
    nice soufflé.</p>
<hr color="blue"/>
<div id="footer">&copy; All content copyright 2007. Even 
    the unfunny stuff.</div>

Description

The color attribute brightens up the otherwise dull hr element by filling in the hole created by the default beveled appearance.

Value

This attribute takes as its value a recognized color name (for example, "blue" or "red"), or a value specified in hexadecimal notation (such as "#003366"). Note that it’s not possible to use shorthand hexadecimal values in HTML as you can in CSS—for example, you can’t express "#cceeff" as "#cef".

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2None

The hr element display varies between browsers, as is support for the color attribute. While most browsers render the horizontal line with a color, when that attribute is combined with the size attribute, the browsers’ interpretation of color becomes inconsistent. Some display just a colored outline, others fill the space. However, given that color is a deprecated attribute for this element—in fact it was never in any HTML specification to begin with—it’s best to avoid using it altogether, and thereby avoid the potential for validation failure and consistency problems.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters