KodingKaro
HTML · Advanced · Advanced Semantic Architecture

Reusable semantic content patterns

Reusable components should preserve meaning when their content changes, rather than hardcoding semantics to one visual example.

✓ What you will learn in this topic

  • Explain the purpose of Reusable semantic content patterns in a real HTML document.
  • Choose and apply the elements shown in both examples.
  • Recognize the specific mistake described in this lesson.

Concept explanation

A reusable card might represent a product, article, or course, and those are not always the same semantic role. Component APIs should allow the page to supply the right heading level, link behavior, and content. Avoid placing interactive elements inside other interactive elements. Choose sectioning elements based on the content passed in, and make the component’s accessible name understandable without relying on visual position.

Syntax

Build reusable markup around content relationships; parameterize headings and actions instead of forcing one role on every instance.

Example 1: a small page

This card is an article because it presents one self-contained story with a destination link.

<article>
  <h2><a href=\"/stories/river\">River restoration</a></h2>
  <p>A community project returns native plants to the riverbank.</p>
</article>

Expected result: A story card exposes its title as a link and summarizes one project.

Example 2: a practical page

The section has a heading; its child article is a standalone resource with a subordinate heading.

<section aria-labelledby=\"featured-title\">
  <h2 id=\"featured-title\">Featured resources</h2>
  <article><h3><a href=\"/guides/soil\">Know your soil</a></h3><p>Learn a simple soil test.</p></article>
</section>

Expected result: A headed resource collection contains an independently identifiable guide.

Common mistakes

Do not add landmarks and sectioning elements mechanically; too many named regions can make navigation noisy.

Best practices

Document a small semantic pattern library and use it consistently while letting each page’s content determine its structure.

Practice exercise

Propose a semantic template for a documentation site with global navigation, section navigation, an article, an edit history, and related links. Explain landmark names and heading order.

Lesson summary

  • Reusable components should preserve content meaning across different placements and data.
  • Document a small semantic pattern library and use it consistently while letting each page’s content determine its structure.

Knowledge check

Why should a reusable card not always be hardcoded as article?

Show the explanation

Because the card’s content may not form a self-contained composition in every use; its semantics depend on context.

Practical example

html
<article>
  <h2><a href=\"/stories/river\">River restoration</a></h2>
  <p>A community project returns native plants to the riverbank.</p>
</article>

Expected result:

A story card exposes its title as a link and summarizes one project.

Hands-on practice task

Propose a semantic template for a documentation site with global navigation, section navigation, an article, an edit history, and related links. Explain landmark names and heading order.

In this section

Other lessons in Advanced Semantic Architecture

Broaden your knowledge

Related learning topics