HTML <hr> widthAttributes

HTML hr 标签参考手册HTML <hr> Tag

Examples

A horizontal line with a width of 50%:

<hr width="50%">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Although the width attribute is deprecated, it is still supported by all major browsers.


Definition and Usage

HTML5 does not support the <hr> width attribute. Use CSS instead.

In HTML 4.01, the width attribute of <hr>is deprecated。

The width attribute specifies the width of the horizontal rule, in pixels or percentages.


Compatibility Notes

In HTML 4.01, the width attribute of <hr> is deprecated. Use CSS instead.

CSS syntax: <hr style="width:50%">

CSS Example: Set the width of the <hr> element

In our CSS tutorial, you can find more aboutwidth attributedetails.


Syntax

<hr width="pixels|%">

Attribute Values

Value Description
pixels Specifies the width in pixels (e.g. "100px" or just "100").
% Specifies the width as a percentage of available space (e.g. "50%").


HTML hr 标签参考手册HTML <hr> Tag Other Extensions