Empty elements

Some HTML elements will never have content. Generally, these are elements that insert something into the page, such as an image or a form field.

Perhaps the simplest of the empty elements is the br or “break” element. As an empty element, it has no closing tag. It looks like this: <br>

The br element is a bad element. It is probably the most abused element in all of HTML. Possible exception: headings. The br element is used to add a line break. For example, when printing lines of poetry. This:

<p>
	….the Cambridge ladies do not care, above<br />
	Cambridge if sometimes in its box of<br />
	sky lavender and cornerless,the<br />
	moon rattles like a fragment of angry candy
</p>

Renders like this:

….the Cambridge ladies do not care, above
Cambridge if sometimes in its box of
sky lavender and cornerless,the
moon rattles like a fragment of angry candy

That seems reasonable. So what’s so bad about the br element?

Simply this: devs often abuse it for spacing. They’ll use a string of br elements to push two bits of content apart.

Stylesheets are used for spacing; not HTML elements! Use the br element sparingly, if at all.

There are a few other empty elements, but we will cover them as we need them: just in time.

Next:

Previous: Element nesting

Table of contents