➗HTML <div> tag
dividing up a webpage with "container tags" + other names for <div>
The <div>
tag, as its name implies, can divide an HTML document into more organized sections as such:
However, we will see in the following sections that we can do even better than this!
Semantic HTML
Instead of using <div>
tags to divide an HTML page up, semantic HTML allows us to replace "div
" with more meaningful names such as:
Tag | For |
| the top of a page |
| ...a menu inside a header |
| the main content of the page |
| ...a part of the main content |
| ...(think of a blog or a news site that show a list of posts!) |
| ...related but "optional" content |
| ...encapsulating images/charts/diagrams or similar |
| the bottom of a page |
Note that we could use each of those tags to contain any content, but your fellow developers might not enjoy that! The tags above keep markup organized:
looks a lot more readable than:
Older tags as semantic HTML
We could see tags such as <table>
and <form>
as a pre-cursor to semantic HTML:
their tags say what they are
we could use
<div>
tags and JavaScript to re-create their functionalityobviously, in good practice, we do not!
A note about <figure> and <figcaption>
A <figure>
would contain media (usually an image), while a <figcaption>
to describe that media:
These tag names still confuse me (I have worked with HTML for a long time and I also speak English natively) so have patience with them!
Last updated