Semantic Page Layout
Solution idea
A semantic layout uses header, nav, main, section, article, and footer to describe the page structure to assistive tech and search engines. The goal is to place content in the correct landmarks with a clear heading hierarchy so the page is navigable even without CSS and the document outline is meaningful and consistent.
Public interview reports
These public, self-reported interview accounts informed this practice version. The exercise is modelled on reported rounds, not copied from them, and the reports are not verified official questions or endorsements.
- Taro: Tesla front end developer interview, 2022
The virtual onsite in this self-reported loop asked to replace the divs of a given page with appropriate HTML5 elements. This item practises the semantic layout.
Reported in a public Tesla interview account. Tesla frontend interview questions
Solution
Overview
A semantic layout uses header, nav, main, section, article, and footer to describe the page structure to assistive tech and search engines. The goal is to place content in the correct landmarks with a clear heading hierarchy so the page is navigable even without CSS and the document outline is meaningful and consistent.
Approach 1 — Replace wrappers with semantic layout
Create a header with an h1, a nav for links, a main containing two articles, and a footer. Each article should include an h2 and a section for the body. Avoid extra div wrappers unless needed, and keep heading levels consistent to reflect the document outline and meet the tests. Ensure there is exactly one main element and that semantic elements are used for structure, not presentation.
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>
Semantic Page Layout
</title>
</head>
<body>
<header>
<h1>
My Blog
</h1>
<p>
Welcome to your semantic HTML layout exercise.
</p>
</header>
<main>
<article>
<h2>
First Post
</h2>
<section>
<p>
This is the first article’s main content.
</p>
</section>
</article>
<article>
<h2>
Second Post
</h2>
<section>
<p>
This is the second article’s main content.
</p>
</section>
</article>
</main>
<footer>
<p>
Footer placeholder.
</p>
</footer>
</body>
</html>body {
font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
margin: 2rem;
line-height: 1.6;
}
header, footer {
background: #f5f5f5;
padding: 1rem;
border-radius: 6px;
}
main {
margin-top: 1.5rem;
}
article {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid #ddd;
border-radius: 4px;
}
article h2 {
margin-top: 0;
}Notes & Pitfalls
Don’t change CSS/JS — tests expect structure only. Ensure there is exactly one <main> and exactly two <article> elements. Each <article> must include both an <h2> and a <section> (not just a <div>).
Use one clear page hierarchy: header → main → article/section → footer. Put the page’s primary heading (<h1>) inside <header>.
Resources
Similar questions
Guides
Preparing for interviews? Use Frontend Coding Challenges first, then move into a concrete Study Plan before targeted Company Prep.
Built in public
The code behind FrontendAtlas lives on GitHub. A star helps other frontend engineers find it.