Skip to main content

Rule Four - Every start tag needs a stop tag

For example: <b>every</b> Each start bold has a matching stop bold tag.

So how do you handle the single elements such as <hr>, <br/>, and <img>?

Simply add a space and a forward slash ( /) before the greater than ">" sign.

So the valid way to write these tags is:

<hr />, <br />, and <img />

The space is used to fool old browers. When a browser reads a tag that isn't in its dictionary, it simply discards it. By including a space before the slash "/" the older browsers see and recognize the <br and display a line break. Without the space the old browsers would see <br/> which isn't in their dictionary and it would be discarded without a line break being displayed.

And of course, new XHTML browsers read the entire element and handle it properly.

Don't confuse this with all the other elements that have double tags.

There's a difference in the order.

Double tag elements have the / right after the < in the closing tag: </p>

Single tag elements have the slash before the > <br />