Void elements are HTML elements that cannot have any content or children, so they have no end tag. Examples are <br>, <img>, <hr>, <input>, <meta> and <link>. You write them as a single start tag, such as <br> or <img src="cat.jpg" alt="A cat">, and the browser closes them automatically. Learning the list of html void elements saves you from invalid markup and odd rendering.
Most elements have a start tag, content and an end tag, for example <p>Text</p>. A void element is different: it represents something that cannot wrap content. A line break, an image, a horizontal rule and a form input have nothing meaningful to put between tags, so the specification says they have no end tag and no children.
In each case the element is complete after its start tag. The DOM node for <br> never has child nodes, whatever you write.
The HTML living standard defines these void elements:
| Element | Purpose |
|---|---|
<area> | Clickable region inside an image map |
<base> | Base URL for relative links |
<br> | Line break |
<col> | Column properties inside a table column group |
<embed> | External content or plugin |
<hr> | Thematic break, shown as a horizontal rule |
<img> | Image |
<input> | Form control |
<link> | External resource such as a stylesheet |
<meta> | Document metadata |
<source> | Media source inside <picture>, <audio> or <video> |
<track> | Subtitles or captions for media |
<wbr> | Optional line-break opportunity in a long word |
Older lists also include <param>, <keygen> and <command>. These are obsolete and should not be used in new pages.
In HTML you can write a void element in two ways:
Both are valid HTML. The slash is allowed but ignored by the parser. It is required in XHTML and in some JSX-style syntaxes, and is optional in plain HTML, so choose one style and stay consistent.
What you must not do is write an end tag or put content inside:
The parser treats </br> as a stray end tag and interprets it as another line break, which produces two breaks. Text after an <img> is simply text that follows the image, not its content.
A trap for people coming from XML: self-closing syntax does not work on non-void elements. <div /> is not a closed div in HTML. The parser ignores the slash and the element stays open, so all following content ends up inside it.
Because void elements have no content, all of their information lives in attributes. For example:
<img> uses src, alt, width, height, loading.<input> uses type, name, value, required, placeholder.<meta> uses charset, name, content.<link> uses rel, href.Always give <img> an alt attribute. Use an empty alt="" when the image is purely decorative so screen readers skip it.
<br> is for line breaks that belong to the content, such as lines of an address or a poem. It is not for spacing between paragraphs. Use separate <p> elements and CSS margins for that.
<hr> is a thematic break, a change of topic within a section. Do not use it only for decoration, because CSS borders do that better.
They cannot contain anything, so a closing tag would have nothing to enclose. The parser closes them as soon as it reads the start tag.
Both are valid in HTML5. The slash is optional and ignored. Use whichever your team prefers, and keep it consistent.
No. An <img> never has children. Put the description in the alt attribute and use <figure> and <figcaption> for a visible caption.
No. <script> always needs an end tag, even when you use the src attribute and it has no content. The same applies to <iframe> and <div>.
Void elements such as <br>, <img>, <hr>, <input>, <meta> and <link> have no content and no end tag. Write only the start tag, put the information in attributes, and never add a closing tag. The slash in <br /> is optional in HTML, but self-closing syntax does not close non-void elements like <div>.