Essential storage keeps sign-in and learning features working. Google Analytics measures visits; Microsoft Clarity records interactions to help us improve usability. Both are optional and stay off until you choose. Read our privacy policy.
Structure a semantic news article coding exercise | SovranCode
Study the question, then follow the complete answer and its reasoning.
01 · QUESTION
What should the HTML contain?
Replace generic containers with meaningful landmarks and article elements so a short community news page has a clear, navigable structure.
Requirements
Use header, nav, main, article, and footer elements
Give the article one h1 and at least one h2
Add a navigation link to #details
Use a time element with datetime=2026-09-09
Key idea
Use header and nav for the site introduction, main for unique page content, article for the story, and footer for closing information.
02 · SOLUTION
Complete HTML answer
<header>
<p>Neighborhood Journal</p>
<nav aria-label="Article navigation">
<a href="#details">Opening details</a>
</nav>
</header>
<main>
<article>
<header>
<h1>Community garden opens</h1>
<p>Published <time datetime="2026-09-09">September 9, 2026</time></p>
</header>
<p>Residents transformed an empty lot into a shared garden.</p>
<section id="details">
<h2>Opening details</h2>
<p>The garden opens every Saturday at 09:00.</p>
</section>
</article>
</main>
<footer>Report by the community desk.</footer>
03 · EXPLANATION
Why this solution works
Landmarks expose the page's major regions, while article identifies a self-contained story. Heading levels describe the story's hierarchy. The fragment link targets a stable section ID, and datetime provides an unambiguous machine-readable date.
Concepts demonstrated
Choose elements by meaning
Create a useful document outline
Represent publication dates with time
Why this pattern matters
A news page is more than a stack of boxes. Landmarks let readers and assistive technology move between major regions, while article identifies a story that could stand on its own. Structured publication dates and reliable fragment links also make the content easier for software to interpret and people to navigate.
Solution walkthrough
The page header introduces the publication and contains a labeled navigation region.
The main landmark contains the unique story rather than repeated site-wide content.
The article has its own header, h1, publication time, and a clearly headed details section.
The navigation href and section id use the same fragment, so the in-page link works.
Common mistakes to avoid
Using div for every region even when a semantic element fits
Choosing headings by font size instead of hierarchy
Writing a human date without a machine-readable datetime value
EXERCISE FAQ
Before you move on.
What does “Structure a semantic news article” teach?
This beginner HTML exercise focuses on Choose elements by meaning, Create a useful document outline, Represent publication dates with time. Its requirements define the exact behavior to implement before you write code.
How should I validate this HTML solution?
Start with the displayed example input and expected output, then test a boundary case suggested by the requirements. Edit the HTML, inspect the live preview, then run the checks before comparing your structure with the complete answer.
When should I open the reference solution?
Attempt Structure a semantic news article first. Then open the read-only solution file to compare the contract, edge-case handling, and implementation choices—not simply to copy the final code.