HTML & CSS Interview Question #9

What is semantic HTML?

HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner

Quick Interview Answer

Semantic HTML uses elements whose names communicate the meaning and role of their content. Examples include header, nav, main, article, section, aside, footer, button, and form.

Detailed Explanation

Semantic HTML uses elements whose names communicate the meaning and role of their content. Examples include header, nav, main, article, section, aside, footer, button, and form.

Semantic markup improves document structure, maintainability, accessibility, and machine understanding. It is generally preferable to using generic div or span elements when a native HTML element accurately represents the content.

Code Example

<main>
    <article>
        <header>
            <h1>HTML Interview Guide</h1>
        </header>
        <section>
            <h2>Fundamentals</h2>
            <p>Start with semantic HTML.</p>
        </section>
    </article>
</main>