HTML Basics
Stanford University Libraries & Academic Information Resources

Horizontal Rule

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]

Like <br>, this is an empty element. That is, there must be no end-tag. It is simply inserted anywhere a horizontal rule--a line drawn all the way across the display--is desired. It is frequently used to help mark sections of a page.

<Hr> normally occurs between paragraphs, headings, etc., and it can not occur within paragraphs or headings. It can only occur within body (which is another way of saying 'betwen elements'), inside a form, or within pre (preformatted text)

Example


    <h1>Welcome to my home page</h1>
    <hr>
    <h2>The Blahs</h2>
    <p>blah, blah, blah</p>

Sometimes, rather than using the <hr> tag, an author uses an inline image of a ruled line, in order to give some variety to the page.

<Hr> cause the line to be drawn by the browsing software, so it will be very fast (the browser doesn't have to retrieve an image). Also, and perhaps more importantly, <Hr> is device-independent. That is, it will draw a line across whatever display the user is using, whether it's wide or narrow (character mode browsers draw a line of underscores or hyphens), where the img retrieves a fixed size image that may or may not fill the width of the users display.

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]

Walter Henry
Stanford University Libraries and Academic Information Resources