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.

Where <header> sits in a page<header> logo and title<nav> main menu<main> the page content (<section>, <article>, <aside>)<footer> copyright and links
Where <header> sits in a page

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.

Tip:header does not create a heading. Put an h1 to h6 inside it.
Example: <header>Try it Yourself

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.

Where <nav> sits in a page<header> logo and title<nav> main menu<main> the page content (<section>, <article>, <aside>)<footer> copyright and links
Where <nav> sits in a page

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.

AttributeMeaning
aria-labelnames the menu when a page has more than one nav
Tip:Usually a ul list of links goes inside nav.
Example: <nav>Try it Yourself

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.

Where <main> sits in a page<header> logo and title<nav> main menu<main> the page content (<section>, <article>, <aside>)<footer> copyright and links
Where <main> sits in a page

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.

Tip:Keyboard users and screen readers can skip straight to main, so skip links usually point to it.
Example: <main>Try it Yourself

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.

A section groups a topich2psection(Features)h2psection(Pricing)main
A section groups a topic

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.

Tip:A good test: if the section would not need a heading, it is probably a div.
Example: <section>Try it Yourself

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.

An article stands on its ownheaderpfooterarticle(blog post)main
An article stands on its own

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?

Tip:Articles can be nested. A blog post (article) can hold comments (articles).
Example: <article>Try it Yourself

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.

An aside is a side note next to mainarticlemainaside(related)body
An aside is a side note next to main

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.

Example: <aside>Try it Yourself

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.

Where <footer> sits in a page<header> logo and title<nav> main menu<main> the page content (<section>, <article>, <aside>)<footer> copyright and links
Where <footer> sits in a page

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.

Tip:Like header, a page can have more than one footer.
Example: <footer>Try it Yourself

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.

Heading levels make an outline (this is h1)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h1)

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.

Tip:Do not choose a heading level because of its size. Use CSS for size.
Example: <h1>Try it Yourself

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.

Heading levels make an outline (this is h2)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h2)

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.

Tip:Do not skip from h1 to h3.
Example: <h2>Try it Yourself

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.

Heading levels make an outline (this is h3)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h3)

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.

Example: <h3>Try it Yourself

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.

Heading levels make an outline (this is h4)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h4)

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.

Example: <h4>Try it Yourself

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.

Heading levels make an outline (this is h5)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h5)

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.

Example: <h5>Try it Yourself

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.

Heading levels make an outline (this is h6)h1 Page titleh2 Sectionh3 Subsectionh4 Detailh5 Deep detailh6 Deepest
Heading levels make an outline (this is h6)

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.

Example: <h6>Try it Yourself

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.

<hgroup> is a block (section). It goes inside: body, header, section.... It can contain: one heading plus p subtitles.<hgroup ...>content(children)</hgroup>
<hgroup> is a block (section). It goes inside: body, header, section.... It can contain: one heading plus p subtitles.

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.

Example: <hgroup>Try it Yourself

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.

<address> is a block. It goes inside: body, footer, article.... It can contain: contact details.<address ...>content(contact details)</address>
<address> is a block. It goes inside: body, footer, article.... It can contain: contact details.

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.

Tip:Browsers show it in italics by default. Use br for line breaks inside it.
Example: <address>Try it Yourself

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.

<search> is a block (section). It goes inside: body, header, main.... It can contain: a search form.<search ...>content(a search form)</search>
<search> is a block (section). It goes inside: body, header, main.... It can contain: a search form.

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.

Example: <search>Try it Yourself

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.

<div> is a block. It goes inside: body and most elements. It can contain: anything.<div ...>content(anything)</div>
<div> is a block. It goes inside: body and most elements. It can contain: anything.

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.

AttributeMeaning
class, id, styleused to style or find the box
Tip:Too many nested divs make code hard to read. Prefer meaningful elements first.
Example: <div>Try it Yourself

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.

<p> is a block. It goes inside: body, section, article, div.... It can contain: text and inline elements.<p ...>content(text and inline elements)</p>
<p> is a block. It goes inside: body, section, article, div.... It can contain: text and inline elements.

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.

Tip:A paragraph cannot hold another paragraph or a block element like div.
Example: <p>Try it Yourself

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.

<hr> is a void (no end tag). It goes inside: body, section, div.... It can contain: nothing.<hr ...>no contentno end tag
<hr> is a void (no end tag). It goes inside: body, section, div.... It can contain: nothing.

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.

Tip:In HTML5 it means a thematic break, not just a line.
Example: <hr>Try it Yourself

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.

<br> is a void (no end tag). It goes inside: inline text. It can contain: nothing.<br ...>no contentno end tag
<br> is a void (no end tag). It goes inside: inline text. It can contain: nothing.

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.

Example: <br>Try it Yourself

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.

<pre> is a block. It goes inside: body, section.... It can contain: preformatted text.<pre ...>content(preformatted text)</pre>
<pre> is a block. It goes inside: body, section.... It can contain: preformatted text.

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.

Tip:Special characters like < and & must still be written as entities.
Example: <pre>Try it Yourself

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.

<blockquote> is a block. It goes inside: body, section, article.... It can contain: paragraphs.<blockquote ...>content(paragraphs)</blockquote>
<blockquote> is a block. It goes inside: body, section, article.... It can contain: paragraphs.

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.

AttributeMeaning
citeaddress of the source
Tip:Use figure and figcaption to name the author.
Example: <blockquote>Try it Yourself

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.

figure groups media with a captionimgfigcaptionfigure
figure groups media with a caption

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.

Example: <figure>Try it Yourself

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.

<figcaption> is a block. It goes inside: figure. It can contain: text and inline elements.<figcaption ...>content(text and inline elements)</figcaption>
<figcaption> is a block. It goes inside: figure. It can contain: text and inline elements.

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.

Example: <figcaption>Try it Yourself

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.

A list holds li itemslililiul
A list holds li items

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.

Tip:Remove the bullets with CSS list-style:none when you build a menu.
Example: <ul>Try it Yourself

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.

An ordered list counts its li itemsli (1)li (2)li (3)ol
An ordered list counts its li items

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.

AttributeMeaning
startfirst number
reversedcount down
type1, a, A, i or I
Tip:Change the marker style with CSS list-style-type.
Example: <ol>Try it Yourself

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.

li lives inside a listliliul or ol
li lives inside a 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.

AttributeMeaning
valuesets the number of this item in an ol
Example: <li>Try it Yourself

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.

<menu> is a block list. It goes inside: body, section.... It can contain: li elements.<menu ...>content(li elements)</menu>
<menu> is a block list. It goes inside: body, section.... It can contain: li elements.

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.

Example: <menu>Try it Yourself

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.

Terms and descriptionsdt termdd meaningdt termdd meaningdl
Terms and descriptions

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.

Example: <dl>Try it Yourself

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.

<dt> is a list item. It goes inside: dl. It can contain: text, inline.<dt ...>content(text, inline)</dt>
<dt> is a list item. It goes inside: dl. It can contain: text, inline.

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.

Example: <dt>Try it Yourself

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.

<dd> is a list item. It goes inside: dl. It can contain: text and block content.<dd ...>content(text and block content)</dd>
<dd> is a list item. It goes inside: dl. It can contain: text and block content.

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.

Example: <dd>Try it Yourself

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.

details has two statesClosedOnly the summary showsClick to openOpensummary + hidden contentClick to close
details has two states

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.

AttributeMeaning
openshows the box opened
namegroups several details so only one stays open
Tip:Add open only when the content is important enough to show by default.
Example: <details>Try it Yourself

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.

<summary> is a block interactive. It goes inside: details. It can contain: text and inline.<summary ...>content(text and inline)</summary>
<summary> is a block interactive. It goes inside: details. It can contain: text and inline.

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.

Example: <summary>Try it Yourself

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().

<dialog> is a block interactive. It goes inside: body, section.... It can contain: any content.<dialog ...>content(any content)</dialog>
<dialog> is a block interactive. It goes inside: body, section.... It can contain: any content.

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.

AttributeMeaning
openshows the dialog
Tip:A form with method="dialog" inside it closes the dialog when submitted.
Example: <dialog>Try it Yourself

A popup window.

Quick quiz

1. Which tag is the page footer?

2. Which is a self contained piece?

3. hgroup groups

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.

My notes
Ask a question about this lesson