Semantic markup chooses HTML elements for the meaning or purpose of their content rather than for default visual presentation. It gives browsers a clearer document structure and supports maintainability, accessibility, SEO, and cross-browser compatibility. section 2.1
Explain these common semantic roles in an interview:
- <header> introduces page or content-group information; <main> identifies the primary content; <nav> groups navigation; and <footer> contains closing or copyright information. section 2.1 section 2.5
- Use headings such as <h1>, <h2>, and <h3> to express hierarchy, then separate content from presentation with CSS. section 2.1 section 2.5
- Expect follow-up questions about accessibility, SEO, ARIA attributes, standard HTML APIs, and cross-browser interactions. section 2.1 section 2.5
Article component interview scenario
A candidate builds a React article page with <main>, <article>, and <header>. The header contains the title and subtitle; mapped <section> elements contain headings, subsections, and paragraphs. A semantic structure demonstrates reasoning beyond visual layout. section 2.1
Listing 2.2 The BlogPost <main> element defined using semantic elements
<main>
<article>
<header>
<h1>{post.title}</h1>
<h2>{post.subtitle}</h2>
</header>
{post.sections.map((section, index) => (
<section key="{index}">
<h3>{section.title}</h3>
{section.subsections.map((subsection, subIndex) => (
<div key="{subIndex}">
<h4>{subsection.title}</h4>
<p>{subsection.content}</p>
</div>
))}
</section>
))}
</article>
</main>
Inspect a JSX implementation that maps article sections into nested semantic elements. section 2.1






