Containers, hero sections, content sections, cards, callouts, buttons, and feature lists — the reusable building blocks professional websites are made from
Up to this point, you have learned how to build individual HTML pages, apply CSS styling, create responsive layouts with Flexbox and Grid, and write JavaScript that responds to user actions and updates the DOM. You have the fundamental tools. Now you begin learning how to think like a website builder rather than a page builder.
Real websites are not single pages. They are systems of pages that share a consistent visual language, repeating structural patterns, and reusable building blocks. A well-built website uses the same card style in ten different places. It uses the same button style throughout. Its hero section follows a pattern that could appear on multiple pages with different content. Its spacing, colors, and typography come from a shared design vocabulary rather than being invented fresh for each page.
This chapter teaches you how to design and build those reusable building blocks: page sections. You will learn how to identify sections as patterns, how to write HTML that makes sections reusable, how to write CSS that makes section styles consistent and easy to maintain, and how to assemble a complete page from these sections the way a professional web developer would.
By the end of this chapter, you will be able to look at any well-built website and recognize its section structure. You will also be able to build a page from your own reusable components rather than styling every element from scratch each time — the same mental model used by modern component-based frameworks like React and Vue, built here with plain HTML and CSS.
By the end of this chapter, you should be able to:
Open almost any website and look carefully at its structure. Beneath the visual design, you will notice the same fundamental pattern: the page is divided into horizontal bands of content, each serving a clear purpose.
A typical homepage might have a large banner at the top with a headline and a call-to-action button, a row of feature cards explaining what the site offers, a section with a bold statement and a supporting description, another row of cards with images and short descriptions, a strip with contact information or a newsletter signup, and a footer with links and copyright information.
Each of these bands is a section: a self-contained unit of content and layout that can be designed once and reused with different content wherever it is needed.
Think of a section as having three layers: a container that controls the section's maximum width and horizontal centering on the page, a section wrapper that controls the section's background color, padding, and vertical spacing, and section content that holds the actual text, images, cards, or other elements.
This three-layer structure appears so consistently across professional websites that it is worth memorizing before you write a single line of code.
<!-- The three-layer pattern -->
<section class="hero"> <!-- Layer 2: background, padding, spacing -->
<div class="container"> <!-- Layer 3: max-width, centering -->
<h1>Welcome to My Site</h1>
<p>A place for learning.</p>
<a href="lessons.html" class="btn btn-primary">Start Learning</a>
</div>
</section>
/* Layer 2: controls the section's visual treatment */
.hero {
background-color: var(--color-primary);
padding: var(--space-xl) var(--space-md);
}
/* Layer 3: controls content width and centering */
.container {
max-width: 1100px;
margin-inline: auto;
}
Notice that the .container class appears inside many different sections. It is a reusable utility: it does not know or care what section it is inside. It simply centers content and limits its width. You will write many sections in this chapter, and every one of them will follow this pattern.
Before you can build any section, you need to understand the container — the single most reused CSS pattern in professional web development.
Without a container, your content stretches the full width of the browser window. On a wide monitor, a paragraph of text might span 1600 pixels across the screen. That is nearly unreadable; comfortable reading line length is roughly 55–75 characters, which in practice means content should usually be no wider than about 700–900 pixels for running text, or up to 1200 pixels or so for wider layouts with multiple columns.
The container fixes this by limiting width and centering the content.
.container {
max-width: 1100px;
margin-inline: auto;
padding-inline: var(--space-md);
}
You may sometimes want a narrower container for reading-focused content and a wider one for full-width layouts.
.container {
max-width: 1100px;
margin-inline: auto;
padding-inline: var(--space-md);
}
.container-narrow {
max-width: 720px;
margin-inline: auto;
padding-inline: var(--space-md);
}
.container-wide {
max-width: 1400px;
margin-inline: auto;
padding-inline: var(--space-md);
}
For this chapter's projects and exercises, you will primarily use .container with a max-width of around 1100px.
An important principle: the container controls content width, not background color. If you want a section to have a colored background that stretches full-width across the screen, you apply the background color to the section element, not the container. The container sits inside the section and keeps the content centered.
<!-- CORRECT: background on section, container inside -->
<section class="highlight-band">
<div class="container">
<h2>Our Mission</h2>
<p>We help students learn to build for the web.</p>
</div>
</section>
.highlight-band {
background-color: var(--color-accent-light);
padding-block: var(--space-xl);
}
This gives you a full-width colored band with centered content inside — a pattern you will see on nearly every professional website.
The hero section is the first large section at the top of a page, designed to orient the visitor, convey the site's purpose, and invite action. It typically appears before the navigation on marketing pages, or just after the navigation on informational sites.
A basic hero section contains a headline (the primary message), a subheading or short description (supporting context), one or two call-to-action buttons (the primary action you want visitors to take), and optionally an image or illustration.
<section class="hero">
<div class="container">
<div class="hero-content">
<h1 class="hero-title">Learn Web Development from the Ground Up</h1>
<p class="hero-description">
Structured lessons, hands-on projects, and everything you need
to build real websites with HTML, CSS, and JavaScript.
</p>
<div class="hero-actions">
<a href="lessons.html" class="btn btn-primary">Start Learning</a>
<a href="about.html" class="btn btn-secondary">About This Site</a>
</div>
</div>
</div>
</section>
/* Hero section */
.hero {
background-color: var(--color-primary-dark);
color: var(--color-text-on-dark);
padding-block: var(--space-2xl);
text-align: center;
}
.hero-title {
font-size: var(--text-4xl);
font-weight: 700;
line-height: 1.15;
margin-bottom: var(--space-md);
}
.hero-description {
font-size: var(--text-lg);
line-height: 1.7;
max-width: 640px;
margin-inline: auto;
margin-bottom: var(--space-lg);
color: var(--color-text-on-dark-muted);
}
.hero-actions {
display: flex;
gap: var(--space-sm);
justify-content: center;
flex-wrap: wrap;
}
A common variation places text on the left and an image on the right in a two-column layout.
<section class="hero">
<div class="container">
<div class="hero-layout">
<div class="hero-content">
<h1 class="hero-title">Learn Web Development from the Ground Up</h1>
<p class="hero-description">
Structured lessons, hands-on projects, and everything you need
to build real websites with HTML, CSS, and JavaScript.
</p>
<div class="hero-actions">
<a href="lessons.html" class="btn btn-primary">Start Learning</a>
</div>
</div>
<div class="hero-image">
<img src="images/hero-illustration.png" alt="Student working at a computer" />
</div>
</div>
</div>
</section>
.hero-layout {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--space-xl);
align-items: center;
}
/* On small screens, stack the columns */
@media (max-width: 700px) {
.hero-layout {
grid-template-columns: 1fr;
}
.hero-image {
order: -1; /* Move image above text on mobile */
}
}
This two-column hero uses CSS Grid for layout and includes a responsive breakpoint so that on small screens the two columns collapse into a single vertical stack.
Not every section of a page is a hero. Most sections carry supporting information: explanations, feature lists, descriptions, quotes, or calls to action. These content sections are the workhorses of a page.
A basic content section has a heading, perhaps a subheading, and supporting text.
<section class="content-section">
<div class="container">
<div class="section-header">
<h2>What You Will Learn</h2>
<p class="section-subtitle">
This course covers everything from your first HTML page to
publishing a complete multi-page website.
</p>
</div>
<div class="section-body">
<p>
You will begin with how the web works, then move through HTML structure,
CSS styling and layout, JavaScript interaction, multi-page projects,
and finally accessibility, debugging, and deployment.
</p>
<p>
Each part builds on the last. By the end, you will have built a real
website you can share with others.
</p>
</div>
</div>
</section>
.content-section {
padding-block: var(--space-xl);
}
.section-header {
text-align: center;
margin-bottom: var(--space-lg);
}
.section-header h2 {
font-size: var(--text-3xl);
font-weight: 700;
margin-bottom: var(--space-sm);
}
.section-subtitle {
font-size: var(--text-lg);
color: var(--color-text-muted);
max-width: 600px;
margin-inline: auto;
line-height: 1.7;
}
.section-body {
max-width: 720px;
margin-inline: auto;
}
.section-body p {
margin-bottom: var(--space-md);
line-height: 1.8;
}
Pages often alternate between white and light-gray backgrounds to visually separate sections without harsh dividers.
.content-section {
padding-block: var(--space-xl);
background-color: var(--color-bg);
}
.content-section-alt {
padding-block: var(--space-xl);
background-color: var(--color-bg-alt);
}
By giving some sections the .content-section-alt class, you create visual rhythm on the page without adding borders or extra markup.
Cards are one of the most commonly used patterns in web development. A card is a self-contained visual unit that groups related information — typically an image or icon, a title, a short description, and optionally a link or button.
Cards appear in product listings, article previews, team member profiles, course overviews, feature explanations, and resource directories.
The key property of a card is that it is self-contained. Its styles do not depend on what cards surround it. You can put two cards in a row, three cards in a row, four cards in a grid, or one card alone — the card itself stays consistent.
<div class="card">
<img
class="card-image"
src="images/lesson-html.jpg"
alt="Code showing HTML document structure"
/>
<div class="card-body">
<h3 class="card-title">HTML Structure</h3>
<p class="card-description">
Learn how HTML gives every web page its structure, meaning, and
organization using elements, tags, and attributes.
</p>
<a href="lessons/html.html" class="card-link">Start Lesson →</a>
</div>
</div>
.card {
background-color: var(--color-bg-card);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
overflow: hidden;
display: flex;
flex-direction: column;
transition: box-shadow 0.2s ease;
}
.card:hover {
box-shadow: var(--shadow-md);
}
.card-image {
width: 100%;
height: 180px;
object-fit: cover;
display: block;
}
.card-body {
padding: var(--space-md);
display: flex;
flex-direction: column;
flex: 1;
}
.card-title {
font-size: var(--text-xl);
font-weight: 600;
margin-bottom: var(--space-xs);
}
.card-description {
font-size: var(--text-base);
color: var(--color-text-muted);
line-height: 1.6;
margin-bottom: var(--space-md);
flex: 1;
}
.card-link {
font-weight: 600;
color: var(--color-primary);
text-decoration: none;
font-size: var(--text-sm);
align-self: flex-start;
}
.card-link:hover {
text-decoration: underline;
}
When you display multiple cards in a row, their heights may differ because their descriptions have different lengths. Without careful CSS, shorter cards would not align with taller ones.
The solution is to make the .card itself a flex column and give .card-description flex: 1. This tells the description to grow and fill whatever space is available. The result: all cards in a row stretch to the same height, with the link always sitting at the bottom. This is a small technique, but it produces significantly more polished results.
Cards are almost always placed inside a card grid section.
<section class="content-section">
<div class="container">
<div class="section-header">
<h2>Course Lessons</h2>
<p class="section-subtitle">
Six topic areas, from HTML foundations to publishing your first website.
</p>
</div>
<div class="card-grid">
<div class="card"><!-- card content --></div>
<div class="card"><!-- card content --></div>
<div class="card"><!-- card content --></div>
<div class="card"><!-- card content --></div>
<div class="card"><!-- card content --></div>
<div class="card"><!-- card content --></div>
</div>
</div>
</section>
.card-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: var(--space-lg);
}
@media (max-width: 900px) {
.card-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 580px) {
.card-grid {
grid-template-columns: 1fr;
}
}
This three-column grid collapses to two columns on medium screens and one column on small screens. The cards themselves do not change; only their container grid adapts.
A callout is a visually distinct section of content that draws the reader's attention to something important. Callouts appear in documentation, tutorials, educational materials, and anywhere a note, warning, tip, or important message needs to stand out from surrounding content.
Common callout types are: Note (supplementary information), Tip (a helpful suggestion), Warning (something to be careful about), and Important (critical information the reader must not miss).
<div class="callout callout-tip">
<div class="callout-icon" aria-hidden="true">💡</div>
<div class="callout-content">
<strong class="callout-label">Tip</strong>
<p>
You can test your responsive design directly in the browser.
Open Developer Tools, click the device toolbar icon, and choose
a screen size to preview.
</p>
</div>
</div>
.callout {
display: flex;
gap: var(--space-sm);
padding: var(--space-md);
border-radius: var(--radius-md);
border-left: 4px solid transparent;
margin-block: var(--space-lg);
}
.callout-icon {
font-size: 1.5rem;
flex-shrink: 0;
line-height: 1;
margin-top: 0.1em;
}
.callout-content {
flex: 1;
}
.callout-label {
display: block;
font-size: var(--text-sm);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: var(--space-xs);
}
.callout p {
margin: 0;
font-size: var(--text-base);
line-height: 1.6;
}
/* Callout type variations */
.callout-note {
background-color: #e8f0fe;
border-left-color: #1a73e8;
}
.callout-tip {
background-color: #e6f4ea;
border-left-color: #34a853;
}
.callout-warning {
background-color: #fef7e0;
border-left-color: #f9ab00;
}
.callout-important {
background-color: #fce8e6;
border-left-color: #ea4335;
}
The aria-hidden="true" attribute on the icon element tells screen readers to skip it. The callout label ("Tip", "Warning") already communicates the callout type in text, so the decorative icon does not need to be announced. If you prefer not to use emoji icons, you can use a simple left-border callout without an icon — the left border alone communicates visual distinction effectively.
Buttons and links that invite action — calls to action — appear throughout every professional website. A consistent button system makes a site feel designed rather than assembled.
A basic button system includes a primary button for the main action, a secondary button for an alternative action, a ghost button for low-emphasis actions, and a danger button for destructive actions (used in interactive applications).
<a href="lessons.html" class="btn btn-primary">Start Learning</a>
<a href="about.html" class="btn btn-secondary">Learn More</a>
<button type="button" class="btn btn-ghost">Cancel</button>
/* Base button styles */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--space-xs);
padding: 0.6em 1.4em;
font-size: var(--text-base);
font-weight: 600;
font-family: inherit;
line-height: 1;
border-radius: var(--radius-sm);
border: 2px solid transparent;
text-decoration: none;
cursor: pointer;
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
/* Focus styles — critical for keyboard accessibility */
.btn:focus-visible {
outline: 3px solid var(--color-focus-ring);
outline-offset: 2px;
}
/* Primary button */
.btn-primary {
background-color: var(--color-primary);
color: var(--color-text-on-primary);
border-color: var(--color-primary);
}
.btn-primary:hover {
background-color: var(--color-primary-dark);
border-color: var(--color-primary-dark);
}
/* Secondary button */
.btn-secondary {
background-color: transparent;
color: var(--color-primary);
border-color: var(--color-primary);
}
.btn-secondary:hover {
background-color: var(--color-primary);
color: var(--color-text-on-primary);
}
/* Ghost button */
.btn-ghost {
background-color: transparent;
color: var(--color-text);
border-color: var(--color-border);
}
.btn-ghost:hover {
background-color: var(--color-bg-alt);
}
A feature list section presents a set of related items, each with an icon (or visual), a short title, and a brief description. Feature lists communicate what a service offers, what a course covers, what a product does, or what an organization stands for.
<section class="content-section content-section-alt">
<div class="container">
<div class="section-header">
<h2>Why Build with Web Standards</h2>
<p class="section-subtitle">
Learning browser-native HTML, CSS, and JavaScript gives you a foundation
that remains relevant regardless of which tools and frameworks emerge.
</p>
</div>
<ul class="feature-list" role="list">
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">📐</div>
<div class="feature-content">
<h3 class="feature-title">Structural Thinking</h3>
<p class="feature-description">
HTML teaches you to organize content meaningfully before
you think about how it looks.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">🎨</div>
<div class="feature-content">
<h3 class="feature-title">Visual Systems</h3>
<p class="feature-description">
CSS teaches you to build consistent, scalable design systems
rather than applying one-off styles.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">⚡</div>
<div class="feature-content">
<h3 class="feature-title">Controlled Interaction</h3>
<p class="feature-description">
JavaScript teaches you to respond to users, update pages,
and validate input in a structured way.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">♿</div>
<div class="feature-content">
<h3 class="feature-title">Accessible by Default</h3>
<p class="feature-description">
Web standards are built on accessibility. Learning them correctly
means building for all users from the start.
</p>
</div>
</li>
</ul>
</div>
</section>
.feature-list {
list-style: none;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: var(--space-lg);
}
.feature-item {
display: flex;
gap: var(--space-md);
align-items: flex-start;
}
.feature-icon {
font-size: 2rem;
flex-shrink: 0;
line-height: 1;
}
.feature-content {
flex: 1;
}
.feature-title {
font-size: var(--text-lg);
font-weight: 600;
margin-bottom: var(--space-xs);
}
.feature-description {
font-size: var(--text-base);
color: var(--color-text-muted);
line-height: 1.6;
margin: 0;
}
@media (max-width: 640px) {
.feature-list {
grid-template-columns: 1fr;
}
}
The feature list is a list of related items, and <ul> is the correct semantic element. The CSS resets its visual appearance — removing bullets and indentation — but the semantic meaning remains. This matters because screen readers announce lists with context ("list, 4 items") that helps users understand the structure. A set of <div> elements does not carry that meaning.
Throughout this chapter, you have seen patterns like .card, .btn, .container, .section-header, and .feature-list. These are all examples of reusable CSS classes — styles that are defined once and applied wherever they are needed.
Reusable classes are the foundation of maintainable CSS. They stand in contrast to overly specific selectors like section#home div.content h2.big-title that only work in one exact place, inline styles that cannot be shared or updated centrally, and duplicated rules that copy the same declarations into multiple places and must be updated individually when something changes.
A class named .homepage-card describes a location. If you later want to use the same card design on a resources page, the name becomes misleading. A class named .card describes what the element is. It works anywhere.
/* Fragile: tied to one location */
.homepage-card { ... }
.resources-card { ... }
.about-card { ... }
/* Reusable: works anywhere */
.card { ... }
Sometimes you need a card that behaves slightly differently in one context. Use a modifier class alongside the base class rather than duplicating the base styles.
/* Base card */
.card { ... }
/* Modifier: a horizontal card layout */
.card-horizontal {
flex-direction: row;
}
.card-horizontal .card-image {
width: 200px;
height: auto;
flex-shrink: 0;
}
/* Modifier: a featured card with a different background */
.card-featured {
background-color: var(--color-primary);
color: var(--color-text-on-primary);
}
<!-- Standard card -->
<div class="card">...</div>
<!-- Horizontal card -->
<div class="card card-horizontal">...</div>
<!-- Featured card -->
<div class="card card-featured">...</div>
The base .card styles apply to all three examples above. The modifier classes add or override only what differs.
One of the most visible differences between amateur and professional web design is spacing consistency. Amateur designs apply margins and padding with arbitrary numbers: margin-top: 37px here, padding: 22px there. Professional designs use a limited set of spacing values drawn from a spacing scale.
Chapter 18 introduced CSS variables as the foundation of reusable design systems. Here you apply that knowledge to spacing specifically.
A spacing scale is a set of named spacing values that grow in a consistent ratio. Every margin, padding, and gap in your stylesheets should use a value from this scale.
:root {
--space-xs: 0.25rem; /* 4px */
--space-sm: 0.5rem; /* 8px */
--space-md: 1rem; /* 16px */
--space-lg: 1.5rem; /* 24px */
--space-xl: 2.5rem; /* 40px */
--space-2xl: 4rem; /* 64px */
}
With this scale, every spacing decision in your stylesheet is one of these six values. Elements look visually related because they share spacing values. Sections breathe because they use larger spacing. Text within a card is comfortable because it uses medium and small spacing.
When sections stack on a page, each section's top and bottom padding contributes to vertical rhythm: the sense that the page has a consistent beat of content and space. Using consistent padding-block values on sections creates that rhythm.
.content-section {
padding-block: var(--space-xl);
}
.content-section-large {
padding-block: var(--space-2xl);
}
Every section on the page has predictable top and bottom breathing room, and the visual rhythm feels intentional.
Elements within sections should align consistently. If your section header text is centered, center it with text-align: center and a centered max-width block — not by adding large left or right margins on one side. This keeps behavior predictable and responsive-friendly.
Now you have all the components. Let us see how they assemble into a complete page. Here is the full HTML for a homepage that uses the sections you have learned in this chapter. The file is index.html in the root of the project folder.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Student Learning Site</title>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<!-- Navigation (covered in Chapter 26) -->
<header class="site-header">
<div class="container">
<a href="index.html" class="site-logo">LearnWeb</a>
<nav class="site-nav" aria-label="Main navigation">
<ul role="list">
<li><a href="index.html" class="nav-link nav-link-active">Home</a></li>
<li><a href="lessons.html" class="nav-link">Lessons</a></li>
<li><a href="resources.html" class="nav-link">Resources</a></li>
<li><a href="about.html" class="nav-link">About</a></li>
<li><a href="contact.html" class="nav-link">Contact</a></li>
</ul>
</nav>
</div>
</header>
<main>
<!-- Hero Section -->
<section class="hero">
<div class="container">
<h1 class="hero-title">Learn Web Development from the Ground Up</h1>
<p class="hero-description">
Structured lessons, hands-on projects, and everything you need to build
real websites with HTML, CSS, and JavaScript.
</p>
<div class="hero-actions">
<a href="lessons.html" class="btn btn-primary">Start Learning</a>
<a href="about.html" class="btn btn-secondary">About This Site</a>
</div>
</div>
</section>
<!-- Feature List Section -->
<section class="content-section">
<div class="container">
<div class="section-header">
<h2>What You Will Learn</h2>
<p class="section-subtitle">
Six areas of study covering everything from your first HTML tag
to publishing a complete, accessible website.
</p>
</div>
<ul class="feature-list" role="list">
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">🏗️</div>
<div class="feature-content">
<h3 class="feature-title">HTML Structure</h3>
<p class="feature-description">
How to build meaningful, semantic document structure
that works for users and search engines alike.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">🎨</div>
<div class="feature-content">
<h3 class="feature-title">CSS Styling and Layout</h3>
<p class="feature-description">
How to style pages with consistent typography, color, spacing,
Flexbox, Grid, and responsive design.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">⚡</div>
<div class="feature-content">
<h3 class="feature-title">JavaScript Interaction</h3>
<p class="feature-description">
How to respond to user actions, update the page, and
validate forms with browser-native JavaScript.
</p>
</div>
</li>
<li class="feature-item">
<div class="feature-icon" aria-hidden="true">📐</div>
<div class="feature-content">
<h3 class="feature-title">Project Organization</h3>
<p class="feature-description">
How to structure multi-page websites with shared navigation,
clean files, and reusable components.
</p>
</div>
</li>
</ul>
</div>
</section>
<!-- Lesson Cards Section -->
<section class="content-section content-section-alt">
<div class="container">
<div class="section-header">
<h2>Course Lessons</h2>
<p class="section-subtitle">
Browse lessons by topic, from foundations to publishing.
</p>
</div>
<div class="card-grid">
<div class="card">
<img class="card-image"
src="images/lesson-foundations.jpg"
alt="Browser window showing a web page loading" />
<div class="card-body">
<h3 class="card-title">Foundations of the Web</h3>
<p class="card-description">
How the internet works, how browsers request and render pages,
and how to set up your first project folder.
</p>
<a href="lessons/foundations.html" class="card-link">Begin Lesson →</a>
</div>
</div>
<div class="card">
<img class="card-image"
src="images/lesson-html.jpg"
alt="HTML code with semantic elements highlighted" />
<div class="card-body">
<h3 class="card-title">HTML: Structure and Meaning</h3>
<p class="card-description">
Elements, attributes, semantic tags, links, images, forms,
and how to build well-structured HTML documents.
</p>
<a href="lessons/html.html" class="card-link">Begin Lesson →</a>
</div>
</div>
<div class="card">
<img class="card-image"
src="images/lesson-css.jpg"
alt="CSS rules and colorful layout boxes" />
<div class="card-body">
<h3 class="card-title">CSS: Style and Layout</h3>
<p class="card-description">
Selectors, the box model, Flexbox, Grid, responsive design,
custom properties, and reusable style systems.
</p>
<a href="lessons/css.html" class="card-link">Begin Lesson →</a>
</div>
</div>
</div>
</div>
</section>
<!-- Callout / Notice Section -->
<section class="content-section">
<div class="container container-narrow">
<div class="callout callout-tip">
<div class="callout-icon" aria-hidden="true">💡</div>
<div class="callout-content">
<strong class="callout-label">Tip for New Students</strong>
<p>
Start with the Foundations section before jumping ahead. Each part
of this course builds on the last. Taking time to understand how the
web works will make everything else easier.
</p>
</div>
</div>
</div>
</section>
</main>
<!-- Footer (covered in Chapter 26) -->
<footer class="site-footer">
<div class="container">
<p class="footer-credit">Student Learning Site — MGU Web Development</p>
</div>
</footer>
</body>
</html>
This is not a small exercise. This is a real homepage built from reusable sections. Notice how each section can be read independently in the HTML, how each section follows the two-layer container pattern, and how the page assembles like building blocks.
Read the following HTML and answer the questions below.
<section class="content-section content-section-alt">
<div class="container">
<div class="section-header">
<h2>Featured Resources</h2>
<p class="section-subtitle">
Guides, references, and tools for learning web development.
</p>
</div>
<div class="card-grid">
<div class="card card-featured">
<div class="card-body">
<h3 class="card-title">HTML Element Reference</h3>
<p class="card-description">
A complete guide to every HTML element covered in this course,
with usage examples and accessibility notes.
</p>
<a href="resources/html-reference.html" class="card-link">
View Reference →
</a>
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="card-title">CSS Selector Chart</h3>
<p class="card-description">
A printable reference for CSS selectors, specificity,
and the cascade.
</p>
<a href="resources/css-selectors.html" class="card-link">
View Chart →
</a>
</div>
</div>
</div>
</div>
</section>
content-section and content-section-alt. What is the purpose of having two classes on one element instead of a single class?card card-featured. The second card has only card. What styling behavior do you expect to differ between these two cards?.card-image element. How would the .card-body rendering likely differ from a card that does include an image?.container inside the section does not have a modifier class like .container-narrow. What does this tell you about the expected layout width?Read the following CSS and answer the questions.
.feature-list {
list-style: none;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: var(--space-lg);
}
.feature-item {
display: flex;
gap: var(--space-md);
align-items: flex-start;
}
.feature-icon {
font-size: 2rem;
flex-shrink: 0;
}
.feature-content {
flex: 1;
}
@media (max-width: 640px) {
.feature-list {
grid-template-columns: 1fr;
}
}
.feature-list set list-style: none and padding: 0?.feature-icon has flex-shrink: 0. What problem would occur without this declaration?align-items: flex-start do in .feature-item? How would the layout look different with align-items: center?Trace through the following CSS to determine what visual properties the described card would have.
:root {
--color-bg-card: #ffffff;
--color-primary: #1a73e8;
--color-text-on-primary: #ffffff;
--radius-md: 8px;
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
--space-md: 1rem;
--space-xs: 0.25rem;
--text-xl: 1.25rem;
--text-base: 1rem;
--text-sm: 0.875rem;
--color-text-muted: #555;
}
.card {
background-color: var(--color-bg-card);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
overflow: hidden;
display: flex;
flex-direction: column;
transition: box-shadow 0.2s ease;
}
.card:hover {
box-shadow: var(--shadow-md);
}
.card-featured {
background-color: var(--color-primary);
color: var(--color-text-on-primary);
}
.card element (not hovered) has what background color, border radius, and box shadow?.card, what changes and what stays the same?card card-featured has what background color? Why does the .card-featured declaration override .card?.card: background-color, border-radius, box-shadow.Look at the following HTML structure without any CSS. Predict what the browser would display, then describe what it would look like after the CSS in this chapter is applied.
<section class="hero">
<div class="container">
<h1 class="hero-title">Welcome</h1>
<p class="hero-description">Get started today.</p>
<div class="hero-actions">
<a href="#" class="btn btn-primary">Sign Up</a>
<a href="#" class="btn btn-secondary">Learn More</a>
</div>
</div>
</section>
.hero adds a dark background color and padding-block: var(--space-2xl): how does the section's appearance change?.container adds max-width: 1100px and margin-inline: auto: how does content behavior change at a viewport width of 1400px? At 800px?.hero-actions adds display: flex; gap: var(--space-sm); justify-content: center: how do the two buttons appear relative to each other?.btn-secondary adds border: 2px solid var(--color-primary); background-color: transparent; color: var(--color-primary): how does the "Learn More" button visually differ from the "Sign Up" button?The following card has a layout problem. When placed in a three-column grid alongside other cards, it does not match their height, and the link sits in the middle of the card rather than at the bottom. Identify the missing CSS declarations and explain what each one does.
<div class="card">
<img class="card-image" src="images/lesson.jpg" alt="Coding screen" />
<div class="card-body">
<h3 class="card-title">CSS Layout</h3>
<p class="card-description">
Flexbox, Grid, and responsive design.
</p>
<a href="lessons/css.html" class="card-link">Start →</a>
</div>
</div>
.card {
background-color: var(--color-bg-card);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
overflow: hidden;
}
.card-body {
padding: var(--space-md);
}
.card-description {
color: var(--color-text-muted);
}
.card that causes the height problem?.card that prevent it from being a flex column?.card-description that keeps the link from pushing to the bottom?.card and .card-body CSS.The following button has a critical accessibility problem. Identify and fix it.
.btn {
display: inline-flex;
align-items: center;
padding: 0.6em 1.4em;
font-weight: 600;
border-radius: 4px;
text-decoration: none;
cursor: pointer;
transition: background-color 0.15s ease;
}
.btn:focus {
outline: none;
}
.btn-primary {
background-color: var(--color-primary);
color: var(--color-text-on-primary);
}
outline: none on .btn:focus create?.btn:focus rule that maintains keyboard accessibility while providing good visual design.Create a file named container-test.html. Inside a <main> element, create three sections, each with a .container inside. Apply a different background color to each section and set max-width: 800px with margin-inline: auto on the container.
Add enough text to each section to make the experiment readable. Open the file in a browser and resize the window to observe how the container behaves at different widths. Write two sentences describing what you observe when the browser window is narrower than 800px.
Build a set of three cards using the card HTML and CSS from this chapter. Give each card a different-length description — one short, one medium, one long. Apply the full .card CSS including display: flex; flex-direction: column on the card and flex: 1 on .card-description.
Describe in writing what happens to the link position in each card. Then remove flex: 1 from .card-description and observe the difference.
Build all four callout types from this chapter (note, tip, warning, important) on a single HTML page. Each callout should have a different icon, label, and short message.
Without changing the base .callout CSS, use only the modifier classes (.callout-note, .callout-tip, .callout-warning, .callout-important) and CSS variables to control the background and border colors.
Take the four-item feature list from Section 25.8 and adjust the media query breakpoint to see how layout changes. First, change the breakpoint from 640px to 900px and preview the layout. Then change it to 400px. Write one paragraph explaining what breakpoint you would choose for a real website and why.
Project goal: Build a complete single-page website for a fictional student project, school club, or learning resource using the section patterns from this chapter.
Suggested themes: a study guide site for a school subject, a school club website (robotics, drama, coding, art), a local community resource directory, a personal learning portfolio, or a fictional small business.
These questions draw on earlier chapters as well as Chapter 25.
images/ inside the project root. You are writing HTML in a file at lessons/css.html. Write the correct relative path for an image named css-diagram.png.<div class="card-title">Flexbox Layout</div>. What semantic HTML element should replace this <div>, and why does the semantic element matter?card and card-featured. Both classes set background-color. Which one wins, and why?.card has padding: var(--space-md) applied to .card-body and box-sizing: border-box applied globally. If the card's total width is 300px, does the padding add to or subtract from the content area?.hero-actions container uses display: flex; justify-content: center; flex-wrap: wrap. When the viewport is too narrow to show both buttons side by side, what happens?.card-grid uses grid-template-columns: repeat(3, 1fr). At what viewport width does it make sense to add a media query to switch to two columns? What factors would influence this decision?card-active to whichever card a user clicks. Write the JavaScript addEventListener call that would accomplish this when a user clicks any element with the class card.Chapter 25 taught you how to build well-structured, consistent, reusable sections on a single page. The next step is applying those same patterns across multiple linked pages — the home page, the about page, the lessons pages, the resources page, and the contact page — while keeping navigation, headers, footers, and design consistent everywhere.
Chapter 26 covers shared site headers, shared footers, navigation menus, active navigation states, relative paths across nested folders, breadcrumbs, and the discipline of maintaining a multi-page site without a framework. You will build a five-page version of the Student Learning Site that will serve as the foundation for the rest of the course.