Skip to: content, navigation

color (HTML attribute)

Spec
Depr. Version
Yes N/A
Browser support (more…)
IE5.5+ FF1+ Saf1.3+ Op9.5+
Full Full Full Full

Syntax

color="color"

Description

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

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>

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

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
Full Full Full Full Full Full Full Full Full None Full

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

Search