Skip to main content

HTML Semantic Elements

Semantic elements are elements with a meaning.


What are Semantic Elements?

A semantic element clearly describes its meaning to both the browser and the developer. Non-semantic elements like <div> and <span> tell nothing about their content, while semantic elements like <img>, <table>, and <article> clearly define theirs.


Semantic Elements in HTML

Many sites use generic markup like a div for navigation, header, and footer. HTML has semantic elements for these parts instead: <article>, <aside>, <details>, <figcaption>, <figure>, <footer>, <header>, <main>, <mark>, <nav>, <section>, <summary>, and <time>.


HTML <section> Element

The <section> element defines a section in a document. Bootstrap describes a section as a thematic grouping of content, usually with a heading, such as chapters, an introduction, news items, or contact information.

Example

Two sections in a document.

Prompt
A page with two section elements, each grouping a heading and a paragraph: one about the WWF organization and one about WWF's panda symbol.
Output: complete HTML page

HTML <article> Element

The <article> element holds independent, self-contained content that should make sense on its own and could be distributed separately, such as forum posts, blog posts, user comments, product cards, or newspaper articles.

Three articles

Three self-contained articles about browsers.

Prompt
A page with three article elements, each independent and self-contained, describing three web browsers: Google Chrome, Mozilla Firefox, and Microsoft Edge.
Output: complete HTML page

Styled with CSS

Nested articles styled with CSS.

Prompt
A page that uses CSS to style nested article elements: an outer article "Most Popular Browsers" containing three inner browser articles, with light gray and white backgrounds.
Output: complete HTML page

Nesting <article> in <section> or Vice Versa?

The <article> element holds independent, self-contained content, and the <section> element defines a section. Can the definitions tell you how to nest them? No. You will find pages with <section> elements containing <article> elements, and the other way around.


HTML <header> Element

The <header> element is a container for introductory content or a set of navigation links. It usually holds one or more headings, a logo or icon, and authorship information.

Note: You can have several <header> elements in one document, but a <header> cannot go inside a <footer>, <address>, or another <header>.

Example

A header inside an article.

Prompt
A page with an article that contains a header element holding a heading and a short intro, followed by the article's main paragraph, about what WWF does.
Output: complete HTML page

HTML <footer> Element

The <footer> element defines a footer for a document or section. It usually holds authorship, copyright, and contact information, a sitemap, back-to-top links, or related documents. You can have several <footer> elements in one document.

Example

A footer with authorship and contact info.

Prompt
A page with a footer element containing authorship and a contact email link.
Output: complete HTML page

HTML <nav> Element

The <nav> element defines a set of navigation links. Not every link belongs in a <nav>; it is meant only for major blocks of navigation. Screen readers can use it to decide whether to skip this content at first.

Example

A set of navigation links.

Prompt
A page with a nav element holding a set of major navigation links: HTML, CSS, JavaScript, and jQuery, separated by pipes.
Output: complete HTML page

HTML <aside> Element

The <aside> element holds content set apart from the content around it, like a sidebar. It should be only indirectly related to the surrounding content.

Basic aside

An aside next to a paragraph.

Prompt
A page with a paragraph about visiting Epcot, plus an aside element giving extra, indirectly related information about the Epcot center.
Output: complete HTML page

Styled with CSS

An aside styled as a floated sidebar.

Prompt
A page that uses CSS to style an aside element as a right-floated, italic, light gray sidebar next to several paragraphs about visiting Epcot.
Output: complete HTML page

HTML <figure> and <figcaption> Elements

The <figure> tag holds self-contained content like illustrations, diagrams, photos, or code listings. The <figcaption> tag gives a caption for the figure, placed as its first or last child, and the <img> element is the actual image.

Example

An image with a figure caption.

Prompt
A page using a figure element to wrap an image (pic_trulli.jpg) with a figcaption "Fig1. - Trulli, Puglia, Italy."
Output: complete HTML page

Why Semantic Elements?

According to the Bootstrap, a semantic web lets data be shared and reused across applications, enterprises, and communities. Semantic elements help describe the meaning of content rather than just its appearance.


Semantic Elements in HTML

Some semantic elements and what they do: <article> (independent content), <aside> (content aside from the page), <details> (details the user can show or hide), <figcaption> (a caption for a figure), <figure> (self-contained content like a photo), <footer> (a footer), <header> (a header), <main> (the main content), <mark> (marked text), <nav> (navigation links), <section> (a section), <summary> (a heading for details), and <time> (a date or time).