DiscoveryVIP / HTML & CSS AcademyHelp

23. Section and article

Module 5 · About 20 minutes · Lesson 22; review earlier concepts as needed

Open Interactive Lesson

Discover

What changes when you use section and article, and how can you prove it?

Predict

Record the expected structure or visual change before rendering. Name one thing that should remain unchanged.

Understand

article is independently meaningful content, while section groups a topic within a larger document and usually has a heading. Neither is a generic replacement for every div. Use a heading that makes the grouping understandable out of visual context. A collection can contain multiple articles, each with its own heading, within a named section.

Important source lines

index.html:1 <main><h1>Workshop news</h1><section aria-labelledby="updates"><h2 id="updates">Latest updates</h2><article><h3>New layout session</h3><p>Practise Grid with real content.</p></article></section></main>
The document’s principal content, normally one visible instance. Attribute guidance: id useful for skip links.

The first example teaches this lesson’s primary contract. Additional examples are optional related references or applications, each with its own purpose and source; an example without an authored check requires the stated visual/manual review.

Example 1: Section and article

The section’s name refers to its visible heading, and the article describes one update.

index.html

<main><h1>Workshop news</h1><section aria-labelledby="updates"><h2 id="updates">Latest updates</h2><article><h3>New layout session</h3><p>Practise Grid with real content.</p></article></section></main>

styles.css

script.js

Expected: The section’s name refers to its visible heading, and the article describes one update.

Edit and Render This Example
Example 2: Element: section

A thematic grouping, usually identified by a heading.

index.html

<section aria-labelledby="outcomes"><h2 id="outcomes">Learning outcomes</h2><p>Build and explain a page.</p></section>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A thematic grouping, usually identified by a heading. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 3: Element: h2

A second-level heading for a major subsection.

index.html

<h1>Handbook</h1><section><h2>Getting started</h2><p>A named section.</p></section>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A second-level heading for a major subsection. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 4: Element: article

An independently meaningful composition.

index.html

<article><h2>Layout field note</h2><p>This note stands on its own.</p><footer>By Alex</footer></article>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: An independently meaningful composition. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example
Example 5: Element: h3

A third-level heading within a subsection.

index.html

<h1>Handbook</h1><h2>Files</h2><h3>HTML source</h3><p>Document content.</p>

styles.css

body { font:18px/1.6 system-ui; margin:1.5rem; color:#17324d; } img,video,svg { max-width:100%; height:auto; } th,td { padding:.5rem; border:1px solid #a8b8c8; } :focus-visible { outline:3px solid #a44322; outline-offset:3px; }

script.js

Expected: A third-level heading within a subsection. Review its real DOM and native behavior; structural/media-only examples are labeled.

Edit and Render This Example

Build and test

The section’s name refers to its visible heading, and the article describes one update. Repair the current exercise without removing necessary content. Checks inspect the stated structural/computed/stylesheet contract, not exact source text.

Starter index.html

<main><h1>Workshop news</h1><section aria-labelledby="missing"><h2 id="updates">Latest updates</h2><article><h3>New layout session</h3><p>Practise Grid with real content.</p></article></section></main>

Starter styles.css

Objective contract

[
  {
    "type": "attr",
    "selector": "section",
    "property": "aria-labelledby",
    "value": "updates",
    "label": "section has aria-labelledby=updates"
  }
]
Hint 1

Locate the first difference between the intended result and the real preview. Inspect matching elements and computed styles.

Hint 2

The relevant source uses aria-labelledby="updates". The exercise instead uses aria-labelledby="missing". Identify its effect before changing it.

Hint 3

Restore the intended aria-labelledby="updates" operation or implement an equivalent structure/style. Run the actual checks and explain why it works.

Complete reference solution

index.html

<main><h1>Workshop news</h1><section aria-labelledby="updates"><h2 id="updates">Latest updates</h2><article><h3>New layout session</h3><p>Practise Grid with real content.</p></article></section></main>

styles.css

Explain, reflect and extend

Which part of the actual preview or inspector proves this result? Explain one boundary case and name what automated checks do not verify.

Apply this concept to a different realistic piece of content. Predict its structure or visual behavior, test narrow and wide widths where relevant, then record one invalid case and its repair.

Troubleshooting and professional practice

If nothing changes, confirm that you edited the active file and ran Run Preview, or enabled Auto Preview. Inspect the actual DOM because the browser may repair invalid nesting. For CSS, check selector matches, valid declarations, active queries and computed values. Preserve local asset paths and inspect warnings. The section’s name refers to its visible heading, and the article describes one update.

Knowledge check

Explain why the stated result follows from the source. Predict a second input or width and test it independently. Automated contracts and written explanations are reviewed separately.

Optional AI prompts

  1. Explain this lesson’s source line by line using the actual objective above.
  2. Help implement one small extension and define normal, boundary and failure tests.
  3. Review/debug the source against actual preview observations; verify standards and never claim rendering without evidence.

Continue to Lesson 24: Aside and footer

Detailed learning and editor help · Standards reference