HTML Tutorials - Horizontal Rule


The <hr> tag creates a horizontal line in an HTML page and can be used to separate content.  The  <hr> tag only employs a start tag and does not have an end tag.

Using the <hr> tag alone without any attributes or values will draw a horizontal rule at the default height (2 pixels), at the default width (100% of the available horizontal space)

Example:

 

Dear Sir,<br /><br />
<hr />

 

Output in internet explorer would look like:

 

html horizontal rule tutorial

 

The Horizontal Rule has a number of attributes

 

size="pixels" - Using the size attribute in the <hr> tag, you can specify the height of your horizontal rule in pixels.

width="pixels or percentage" - Using the width attribute, you can explicitly set the width of your horizontal rule

align="left, center or right" - you can use the align attribute to position it to the left, in the center or to the right on your web page

 

color="color definition" - you can actually define the color of your horizontal rule using the color attribute.

Example:

Dear Sir,<br /><br />
<hr size="5" color="red" width="50%" align="left" >

 

Output in your browser after saving the file:

html horizontal rule tutorial

 


 

C++ Functions Tutorial