Skip to: content, navigation

by Ian Lloyd

width (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
Yes HTML 3.2
width="width(pixels or %)"

Example

<p>And with that the actress explained to the bishop, through a
series of hand gestures, that she was in fact mute and could not
possibly have said what she was reported to have done.</p>
<hr color="red" size="10" width="50%" />
<div id="footer">&copy; All content copyright 2007. Even the
unfunny stuff.</div>

The image below shows a horizontal rule set at 50% - the red border is added only to show scale.

HR with width attribute

Description

The width attribute affects the hr element’s width in pixels (or percentage, if % symbol included); if no width is specified, the hr will take up 100% of its containing element.

Value

A number wrapped in quotes (which is understood and rendered as pixels on screen no need to specify unit of measurement, as per example above) or percentage figure.

Compatibility

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

The width attribute is well supported but as a deprecated (presentational) attribute, it should not be used.

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