liveBook · Manning

Semantic markup

As explained in Acing the Frontend Interview

A semantic HTML element is an HTML element whose name conveys the structural meaning or purpose of its content.

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

How Acing the Frontend Interview covers it

How deep it goes
Defines semantic element choice and hierarchy, then applies them in a React component without detailing browser internals.
Examples
Uses a favorite-article page with titles, subtitles, sections, subsections, paragraphs, metadata, and copyright.
What it assumes
Assumes basic HTML and frontend knowledge while reinforcing document structure and semantic element choice.
What you can do after
Build semantic article components in JSX and explain their accessibility, SEO, maintainability, and interview significance.
How it connects
Connects HTML, CSS, accessibility, SEO, ARIA attributes, standard HTML APIs, React, and JSX.

Also explained in

Compare how 7 books explain semantic markup →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.