Sub topic 1
The Four Building Blocks of a Page
Prerequisites
Assume you know basic HTML tags and attributes, CSS selectors and properties, and how to open a page in a browser.
The Four Building Blocks of a Page
Most pages have four structural regions:
- Header: identifies the site and provides orientation.
- Hero: presents the page’s main message and primary action.
- Content sections: organize supporting information.
- Footer: closes the page with secondary links and site information.
The hero belongs inside the main content. The header and footer usually surround it.
Semantic Elements: Header, Nav, Main, Section, Footer
Semantic HTML uses elements whose names describe their purpose. These elements create landmarks that browsers and assistive technologies can understand.
<header>contains introductory content for a page or section.<nav>contains a group of navigation links.<main>contains the page’s unique primary content.<section>groups a related part of that content.<footer>contains closing information or secondary links.
<header>
<a href="/">Acme Bakery</a>
<nav aria-label="Primary">
<a href="/menu">Menu</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<section class="hero">
<h1>Fresh bread every morning</h1>
<p>Order ahead for pickup.</p>
</section>
<section>
<h2>Our specialties</h2>
<p>Sourdough, rye, and seasonal pastries.</p>
</section>
</main>
<footer>
<p>© 2026 Acme Bakery</p>
</footer>A common error is using <div> for every region. A <div> has no structural meaning, so it does not communicate the page’s organization.
Headings Give the Page an Outline
Use one <h1> for the page’s main topic. Use <h2> for major sections and <h3> for subsections within them. Do not choose a heading because its default text size looks right. Use CSS for appearance.
The Header: Identity and Orientation
The header should quickly answer two questions: whose site is this, and where can I go? Place the site name or logo and primary navigation there. Give repeated navigation landmarks distinct accessible names, such as aria-label="Primary" and aria-label="Footer".
The header is not the page’s main content. Keep the page-specific heading in <main>.
Exercise
Which element should contain a page’s unique heading and hero content?
Show answer
The <main> element.