C & G web

Horizontal Rule

HR is used to draw horizontal rules across the browser window. If the margins are currently smaller, for example because of images (IMG) which are placed against the margins, the rule will extend to these margins instead of the whole window. A horizontal rule is typically used to separate sections within a document.

In HTML 3.2, the appearance can be controlled more than in HTML 2. You can specify the thickness of the rule with the SIZE attribute, which takes an integer number of pixels. The width of the rule can be specified in number of pixels or as a percentage of the currently available window width, using the WIDTH attribute. Don't forget that percentage values must be quoted! The NOSHADE attribute is used to indicate that the rule should not get its usual shaded appearance, but instead should be drawn as a thick line. Notes:
  • None of the attributes for HR existed in HTML 2, so they may not be supported by all browsers. This can produce bizarre effects if you are using multiple HRs in a row to produce growing or shrinking "stripes".
  • If you use too many rules on a document, the end result can be that the document looks like a "sandwich" because there is little text between each rule.
  • Setting an absolute width is not recommended, since you have no way to know how wide the currently available window is. Use a percentage if you have to change the width.

Example - Horizontal Rule

The Horizontal Rule can be used to...
separate one section from another.

The HTML

<html>
<head>
	<title>The Horizontal Rule</title>
</head>

<body>	
	
The Horizontal Rule can be used to...

<hr>
		
separate one section from another.

</body>
</html>		
		

Previous page...

Computeach International Ltd

Christopher Ward London Limited

Christopher Ward London Limited