Some elements have nothing to wrap, so they have no content and no closing tag. They are called empty elements or void elements.
<p>Line one<br>Line two</p>
<hr>
<img src="https://placehold.co/160x80" alt="A grey placeholder image">
The common ones
| Element | What it does |
|---|---|
<br> | Starts a new line |
<hr> | Draws a horizontal rule, a break between topics |
<img> | Shows an image |
<input> | A form field |
<meta> | Information about the page, in the head |
<link> | Connects a file such as CSS, in the head |
Writing them
Write <br> and not <br></br>. You may see <br /> with a slash in older code. Both work in HTML. Pick one style and use it everywhere. This course uses the version without a slash.
Where the information goes
Since there is no content between tags, the information lives in attributes. An image needs src to know which file to show and alt to describe it. The next lessons explain attributes in detail.
Using br for spacing
<br> should be used for a real line break, such as in an address or a poem. Do not stack several <br> tags to push content down the page. Use CSS margins for spacing.