Home / Learn HTML / Elements: Sections and Content Blocks
Elements: Sections and Content Blocks
Headers, navigation, headings, paragraphs, lists and other blocks that hold your content.
About this lesson
This lesson covers sectioning and block level elements: page parts (header, nav, main, footer), headings, paragraphs, lists, quotes and dialogs. Choosing the right one gives your page a clear outline that people, screen readers and search engines can follow.
The <header> element
The header element is the introduction of a page or of a section. It usually holds a logo, a title, a menu and a search box.
When to use it: Use it for the top of the page and also at the top of an article or section. A page can have many headers.
Why we use it
It marks the introduction of a page or section: logo, title, navigation, search.
How it works
It is a semantic container with no default style. Screen readers announce a banner landmark when it is a direct child of body.
Where it is used
- Site header with logo and menu
- The top of an article with title and author
Common mistakes
It is not the same as head. You can use several headers, one per section or article.
header does not create a heading. Put an h1 to h6 inside it.Intro area of a page or section.
The <nav> element
The nav element marks a block of main navigation links. Screen readers can jump straight to it.
When to use it: Use it for the main menu, a table of contents or breadcrumb links. Do not wrap every group of links in it, only the major ones.
Why we use it
It marks a block of major navigation links so browsers and screen readers can find the menu fast.
How it works
Screen readers list nav regions as landmarks. Inside, a ul of links is the usual pattern.
Where it is used
- Main menu
- Breadcrumbs
- Table of contents
- Pagination
Common mistakes
Do not wrap every group of links. Use it only for main navigation blocks.
| Attribute | Meaning |
|---|---|
aria-label | names the menu when a page has more than one nav |
ul list of links goes inside nav.A block of main links.
The <main> element
The main element holds the central content of the page, the part that is unique to this page.
When to use it: Use it once per page. Do not place it inside header, footer, nav, aside or article.
Why we use it
It wraps the unique, main content of the page that is not repeated on other pages.
How it works
There should be only one visible main per page. It becomes the main landmark so keyboard users can skip straight to it.
Where it is used
- Article body or app area between header and footer
- Skip link target
Common mistakes
Do not put main inside article, aside, header, footer or nav. Only one main is visible.
main, so skip links usually point to it.The main content. Use once per page.
The <section> element
The section element groups related content with a heading. It is a chapter or a themed part of a page.
When to use it: Use it when the content has its own heading and belongs to one theme. If you only need a box for styling, use div.
Why we use it
A section groups related content with a topic, usually with its own heading.
How it works
It is a thematic grouping. When it has an accessible name (a heading or aria-label) it is a region landmark.
Where it is used
- Chapters of a long page
- Features, pricing and FAQ areas on a landing page
Common mistakes
If you only need a styling box use div. Use section when the block has a heading and a theme.
div.A themed group of content with a heading.
The <article> element
The article element marks content that makes sense on its own and could be shared or reused: a blog post, a news story, a product card or a comment.
When to use it: Use it for self contained pieces. Each article should normally have a heading.
Why we use it
It marks content that makes sense by itself and could be shared on its own.
How it works
Search engines and readers can treat the article as a separate item, such as one news story.
Where it is used
- Blog posts
- News stories
- Forum posts and comments
- Product cards
Common mistakes
Do not use it for every box. Ask: could this be copied to another site and still make sense?
A complete piece that makes sense alone.
The <aside> element
The aside element holds content that is related to the main content but is not essential to it: a side note, a pull quote, related links or an advertisement.
When to use it: Place it beside or inside the content it relates to. Removing it should not change the meaning of the main text.
Why we use it
It marks content related to the main content but not required to understand it.
How it works
It becomes a complementary landmark. Screen readers can skip it.
Where it is used
- Sidebars
- Related links
- Pull quotes and ads
- Author boxes
Common mistakes
Do not use for unrelated layout columns. The content should be a side note.
Side content related to the main text.
The <footer> element
The footer element marks the end of a page or a section. It usually holds copyright text, contact links, author information and small links.
When to use it: Use it at the bottom of the page and, if needed, at the bottom of an article or section.
Why we use it
It marks the end of a page or section: copyright, legal links, contact.
How it works
When a direct child of body it is the contentinfo landmark.
Where it is used
- Site footer with links
- Article footer with author and date
Common mistakes
It is not only for the bottom of the page. Each article or section can have its own.
header, a page can have more than one footer.Bottom of a page or section.
The <h1> element
The h1 element is the main heading. It tells people and search engines what the page is about.
When to use it: Use exactly one h1 per page and make it match the page title in meaning.
Why we use it
It is the main title of the page. It tells users and search engines what the page is about.
How it works
Browsers draw it as the largest heading. Screen reader users jump from heading to heading to understand the page.
Where it is used
- Page title
- Main headline in a hero section
Common mistakes
Use one h1 per page. Do not choose a heading only for its size. Style with CSS.
Main heading. Use once.
The <h2> element
The h2 element is a major section heading. It sits under the h1.
When to use it: Use it to divide the page into main parts. Each h2 can have h3 sub headings.
Why we use it
It marks a major section under the h1.
How it works
Together h1 to h6 make an outline of the page that screen readers and search engines read.
Where it is used
- Section titles like Features or Pricing
- Subheadings in articles
Common mistakes
Do not skip levels, for example h2 straight to h4.
h1 to h3.Section heading.
The <h3> element
The h3 element is a sub heading under an h2.
When to use it: Use it to split a section into smaller parts.
Why we use it
It marks a subsection under an h2.
How it works
It continues the outline one level deeper.
Where it is used
- Sub topics inside a section
- Card titles inside a grid section
Common mistakes
Keep the order h1, h2, h3. Do not use headings for bold text.
Sub section heading.
The <h4> element
The h4 element is a heading at level four, under an h3.
When to use it: Use it only for deeply nested content, such as details inside a sub section.
Why we use it
It marks a smaller subsection under an h3.
How it works
It is the fourth outline level.
Where it is used
- Detailed docs with deep structure
- Widget titles in sidebars
Common mistakes
Rarely needed. If you reach h4 often, consider splitting the page.
Fourth level heading.
The <h5> element
The h5 element is a heading at level five.
When to use it: Use it rarely. If you need this many levels, consider splitting the page.
Why we use it
It is the fifth heading level for very deep structure.
How it works
It continues the outline. Browsers draw it small.
Where it is used
- Long technical documents
Common mistakes
Not for small text. Use CSS for size.
Fifth level heading.
The <h6> element
The h6 element is the lowest heading level.
When to use it: Use it rarely, for the smallest labelled parts.
Why we use it
It is the lowest heading level.
How it works
It completes the outline of six levels.
Where it is used
- Very deep outlines in manuals
Common mistakes
Almost never needed in normal pages.
Smallest heading.
The <hgroup> element
The hgroup element groups a heading with its subtitle or tagline, so the pair counts as one heading.
When to use it: Use it when a heading has a second line, such as a tagline. Put one h1 to h6 and one or more p inside it.
Why we use it
It groups a heading with its subtitle or tagline so they read as one title.
How it works
It is a wrapper. Screen readers treat the heading as the title and the p as a related line.
Where it is used
- Title with a subtitle
- Hero text with a tagline
Common mistakes
Put only a heading and p elements inside.
Groups a heading with its subtitle.
The <address> element
The address element gives contact information for the author of the page or of an article. It is not for any postal address you like.
When to use it: Use it for the contact details of the person or company responsible for the content, often inside footer.
Why we use it
It marks contact information for the nearest article or the whole page.
How it works
Browsers draw it in italic. Search and assistive tools can recognise it as contact data.
Where it is used
- Author contact in an article
- Business contact in a footer
Common mistakes
Use it for contact details only, not for any postal address mentioned in text.
br for line breaks inside it.Contact details.
The <search> element
The search element wraps a search form or other search controls so that assistive technology can find the search area.
When to use it: Use it around a form that searches the site or filters results. It is a new element.
Why we use it
It marks the part of the page that holds search or filter controls, and becomes a search landmark.
How it works
Screen readers announce it as a search region so users can jump to it.
Where it is used
- Site search boxes
- Product filters
Common mistakes
It is a newer element. For old browser support add role="search" on a form.
Wraps a search form.
The <div> element
The div element is a generic block box with no meaning of its own. It is a container for grouping elements so you can style them or work with them in JavaScript.
When to use it: Use it when no meaningful element (like section or nav) fits. It starts on a new line and takes the full width.
Why we use it
The div is a generic box with no meaning. It is used to group elements for layout and style.
How it works
It starts on a new line and takes the full width. CSS and JavaScript target it by class or id.
Where it is used
- Layout wrappers for flexbox and grid
- Cards, modals and widgets
Common mistakes
Too many nested divs ("div soup"). Use meaningful elements first.
| Attribute | Meaning |
|---|---|
class, id, style | used to style or find the box |
A generic block box.
The <p> element
The p element is a paragraph, a block of text. The browser puts space above and below it.
When to use it: Use it for every paragraph of normal text. Do not use empty paragraphs to make space; use CSS margin.
Why we use it
It holds a paragraph of text.
How it works
The browser adds space above and below and wraps text to the width. A new p automatically closes the previous one.
Where it is used
- Body text in articles
- Descriptions and captions
Common mistakes
Do not use empty p tags for spacing. Use CSS margin. Do not put block elements inside p.
div.A paragraph.
The <hr> element
The hr element is a horizontal rule. It marks a break between topics or sections.
When to use it: Use it for a real change of topic. For decoration use CSS borders instead. It is an empty element.
Why we use it
It marks a thematic break between topics, drawn as a horizontal line.
How it works
The browser draws a line by default. Meaning matters: it says "topic changes here".
Where it is used
- Separating scenes in a story
- Dividing sections of a form
Common mistakes
If you only want a decorative line use CSS border.
A horizontal rule: a theme break.
The <br> element
The br element creates a line break inside text. It is an empty element.
When to use it: Use it where a line break is part of the content, such as in a poem or an address. Do not use it to make spacing between blocks.
Why we use it
It makes a line break inside text.
How it works
The text continues on the next line without starting a new paragraph.
Where it is used
- Poems and song lyrics
- Postal addresses
Common mistakes
Do not use several br to make space. Use paragraphs and margin.
A line break.
The <pre> element
The pre element shows preformatted text. It keeps spaces and line breaks exactly as you typed them and uses a monospace font.
When to use it: Use it for code listings, ASCII art or poems. Put code inside it for code.
Why we use it
It keeps spaces and line breaks exactly as written and uses a monospace font.
How it works
The browser does not collapse whitespace inside pre.
Where it is used
- Showing code
- ASCII art
- Terminal output
Common mistakes
Long lines may scroll sideways. Add overflow: auto in CSS.
Keeps spaces and line breaks.
The <blockquote> element
The blockquote element marks a long quotation taken from another source. Browsers indent it.
When to use it: Use it for quotes that need their own block. For a short quote inside a sentence use q.
Why we use it
It marks a long quotation from another source.
How it works
Browsers indent it. The cite attribute can hold the source URL.
Where it is used
- Quotes in articles
- Testimonials
Common mistakes
For short quotes inside a sentence use q.
| Attribute | Meaning |
|---|---|
cite | address of the source |
figure and figcaption to name the author.A long quotation.
The <figure> element
The figure element wraps self contained content that is referred to from the main text: a picture, diagram, code listing or chart.
When to use it: Use it with an optional figcaption. The content could be moved elsewhere without breaking the main text.
Why we use it
It groups self contained media, like an image, chart or code, with an optional caption.
How it works
The figcaption element gives the figure a caption that assistive tools connect to it.
Where it is used
- Article images with captions
- Charts and diagrams
- Code listings
Common mistakes
Use it for content that can move without breaking the text.
A picture or code with a caption.
The <figcaption> element
The figcaption element is the caption or legend for the content of its parent figure.
When to use it: Place it as the first or last child of figure.
Why we use it
It is the caption or legend of a figure.
How it works
It must be the first or last child of figure.
Where it is used
- Photo credits
- Chart descriptions
Common mistakes
It is only valid inside figure.
The caption inside a figure.
The <ul> element
The ul element is an unordered list, a list where the order of items does not matter. Browsers show bullets.
When to use it: Use it for any group of related items: menus, features, tags. Only li elements may be its direct children.
Why we use it
It makes a bulleted list where order does not matter.
How it works
The browser draws bullets and indents each li.
Where it is used
- Menus and navigation
- Feature lists
- Tag lists
Common mistakes
Only li should be a direct child. Put nested lists inside an li.
list-style:none when you build a menu.Bullet list.
The <ol> element
The ol element is an ordered list. Items are numbered, because the order matters, such as steps in a recipe.
When to use it: Use it for steps, rankings and instructions. Only li children are allowed.
Why we use it
It makes a numbered list where order matters.
How it works
The browser counts the items. Use start, reversed and type to change numbering.
Where it is used
- Steps and instructions
- Rankings and top ten lists
Common mistakes
Use ul if order does not matter.
| Attribute | Meaning |
|---|---|
start | first number |
reversed | count down |
type | 1, a, A, i or I |
list-style-type.Numbered list.
The <li> element
The li element is one item in a list.
When to use it: Use it only inside ul, ol or menu. It can hold text, images and even another list.
Why we use it
It is one item in a list.
How it works
The parent decides the marker: bullet or number.
Where it is used
- Every item in a menu or list
Common mistakes
Do not use li outside a list parent.
| Attribute | Meaning |
|---|---|
value | sets the number of this item in an ol |
One item inside ul, ol or menu.
The <menu> element
The menu element is a list of commands or actions, such as a toolbar. It behaves like ul.
When to use it: Use it for interactive lists of buttons. For site navigation use nav with ul.
Why we use it
It is a list of commands or toolbar actions. It behaves like ul.
How it works
Browsers show it like an unordered list.
Where it is used
- Toolbars with buttons
- Context actions
Common mistakes
For navigation links use nav with ul.
A list of commands.
The <dl> element
The dl element is a description list: pairs of a term and its description.
When to use it: Use it for glossaries, metadata and question and answer pairs. It holds dt and dd elements.
Why we use it
It makes a description list: terms and their meanings.
How it works
Each dt (term) is followed by one or more dd (description).
Where it is used
- Glossaries
- Product specifications
- FAQ style pairs
Common mistakes
Do not mix other elements directly inside. Wrap pairs in div if needed.
Description list.
The <dt> element
The dt element is the term or name in a description list.
When to use it: Use it inside dl, before its dd description.
Why we use it
It is the term in a description list.
How it works
It pairs with the dd that follows it.
Where it is used
- Glossary words
- Spec labels such as Weight
Common mistakes
Use it only inside dl.
The term in a description list.
The <dd> element
The dd element is the description or value of a term in a description list.
When to use it: Use it inside dl after the dt it describes. One term can have several descriptions.
Why we use it
It is the description of a term.
How it works
Browsers indent it under the dt.
Where it is used
- Definitions
- Spec values such as 1.2 kg
Common mistakes
Use it only inside dl.
The description of a term.
The <details> element
The details element is a box the visitor can open and close to show or hide more information. It works without any JavaScript.
When to use it: Use it for FAQs, extra information and long optional text. The first child should be summary.
Why we use it
It makes a show and hide box without JavaScript.
How it works
The user clicks the summary to open or close. The open attribute shows it open at the start.
Where it is used
- FAQ lists
- Extra info and spoilers
- Mobile menus
Common mistakes
Always put a summary first. Content inside is hidden from search in some tools until opened.
| Attribute | Meaning |
|---|---|
open | shows the box opened |
name | groups several details so only one stays open |
open only when the content is important enough to show by default.A box that opens and closes.
The <summary> element
The summary element is the visible title of a details box. Clicking it opens or closes the box.
When to use it: Use it as the first child of details.
Why we use it
It is the visible heading of a details box that people click.
How it works
It shows a small arrow by default. Clicking toggles details.
Where it is used
- FAQ questions
- Show more labels
Common mistakes
Must be the first child of details.
The always visible title of details.
The <dialog> element
The dialog element is a popup window or message box that appears on top of the page.
When to use it: Open it with JavaScript: showModal() for a modal dialog that blocks the page and show() for a normal one. Close it with close().
Why we use it
It is a native popup box. It can be modal and blocks the page behind it.
How it works
show() opens it normally. showModal() opens it modal with a backdrop and handles the Esc key and focus.
Where it is used
- Confirm boxes
- Login popups
- Image viewers
Common mistakes
Prefer showModal() for real dialogs. Always give a close button.
| Attribute | Meaning |
|---|---|
open | shows the dialog |
method="dialog" inside it closes the dialog when submitted.A popup window.
Quick quiz
1. Which tag is the page footer?
footer closes a page or section.
2. Which is a self contained piece?
article stands alone.
3. hgroup groups
Title plus tagline.
Common questions
Which tag is the page footer?
<footer>. footer closes a page or section.
Which is a self contained piece?
<article>. article stands alone.