Beyond the Tags: Mastering HTML Architecture for Product-Based Roles
HTML questions in frontend interviews go past tag names. This guide covers semantic block elements (main, article, section, aside, nav), how the browser turns them into an accessibility tree, why native buttons beat div plus ARIA, how stylesheets and scripts block rendering, and when to use async, defer or type=module. It ends with a semantic dashboard boilerplate.

"What tag makes text bold?" is trivia. A stronger HTML interview question asks how your markup becomes an accessibility tree, or how your script tags change the time to first paint. This guide is for frontend developers preparing for roles at product companies that build dashboards, SaaS tools and high-traffic sites. You'll learn how to choose block elements by meaning, how the browser loads the resources your HTML imports, and how to answer the follow-up questions that trip people up.
This is part 2 of the Frontend & JavaScript Fundamentals series. It follows the frontend developer roadmap, which puts semantic HTML in phase 1.
Key takeaways
- Pick block elements for meaning:
<main>,<nav>,<aside>,<article>and<section>each tell browsers and screen readers what the content is. - Stylesheets block rendering and classic scripts block parsing; load app code with
deferortype="module". - Use a native
<button>beforerole="button": it brings focus and keyboard support for free.
1. Block elements are a decision about meaning
Semantic HTML is markup where each element describes what its content is, not just how it looks. In the early web, pages were built from nested <div> elements. That renders fine, but it hides the structure from search engines and assistive technology.
MDN explains that browsers build an accessibility tree from the DOM. Each object in it has a name, a role, a state and sometimes a description. Screen readers read this tree, not your CSS. A <div> adds no role or landmark to the tree. A <nav> or <main> adds a landmark that users can jump to.
<!-- Avoid: generic boxes -->
<div class="header">...</div>
<div class="sidebar">...</div>
<div class="content">
<div class="post">...</div>
</div>
<!-- Better: each element names its job -->
<header>...</header>
<div class="layout-grid">
<aside>
<nav>...</nav>
</aside>
<main>
<article>
<header><h1>System Architecture</h1></header>
<p>...</p>
</article>
</main>
</div>
The <div class="layout-grid"> stays a <div> on purpose. MDN's <section> page says to use a <div> when you only need a styling wrapper.
What interviewers want you to explain
<main>: MDN defines it as the dominant content of the page. A document must not have more than one visible<main>. Give it anidand a skip link can jump straight to it, past the navigation.<article>versus<section>: an<article>is self-contained content that could be shared on its own, such as a blog post, a comment or a product card. A<section>is a generic part of a document with no more specific element, and it should almost always have a heading.- Headings: older HTML specs allowed an
<h1>in every nested section, and that's now non-conforming. MDN's advice is to prefer one<h1>per page and never skip heading levels, because screen reader users often move from heading to heading.
2. Imports and the critical rendering path
The critical rendering path is the sequence of steps the browser takes to turn HTML, CSS and JavaScript into pixels on screen. Your <link> and <script> tags decide how long that takes, and so how soon First Contentful Paint (FCP) happens. web.dev defines FCP as the time from navigation until any part of the page's content appears.
The two kinds of resource block different things. MDN's guides say:
- CSS blocks rendering. The browser won't paint until it has built the full CSS object model, because later rules can override earlier ones. CSS doesn't stop HTML parsing, but it does hold up scripts.
- Classic scripts block parsing. A
<script>withoutasyncordeferpauses the HTML parser while it downloads and runs. The browser's preload scanner fetches resources early, which softens this, but a large script can still hold up the page.
A tidy <head>
<head>
<!-- 1. If you load fonts from Google Fonts, connect to that origin early -->
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- 2. Preload a font the first screen needs -->
<link rel="preload" href="/fonts/inter-bold.woff2" as="font" type="font/woff2" crossorigin>
<!-- 3. The stylesheet: render-blocking, so keep it small -->
<link rel="stylesheet" href="style.css">
<!-- 4. App code: downloads in parallel, runs after parsing -->
<script src="app.js" defer></script>
</head>
Two details matter here. MDN says preconnect only helps cross-origin requests, so don't point it at your own domain. MDN's preload page says fonts need the crossorigin attribute even when they come from your own origin, or the preloaded file may not be reused.
Fixed in this version
The earlier version labelled the stylesheet "non-blocking CSS". A plain <link rel="stylesheet"> blocks rendering, so it is now labelled as such. The preconnect also pointed at an API domain without saying it must be a different origin.
async versus defer versus module
A plain <script src> in the <head> stops the parser, and the page stays blank until the script runs. MDN's <script> reference describes the alternatives:
| Attribute | When it runs | Order kept? | When to use |
|---|---|---|---|
| none | Right away, pausing the parser | Yes | Rarely; small inline scripts that must run first |
async |
As soon as it downloads | No | Independent scripts such as analytics |
defer |
After parsing, before DOMContentLoaded |
Yes | App code that needs the DOM |
type="module" |
Deferred by default (or as soon as ready with async) |
Yes, without async |
Code that uses import and export |
MDN also notes that defer has no effect on modules, because they already defer, and that modules loaded from another origin need CORS.
3. Interview questions with hidden depth
Some questions sound simple but test your model of the browser.
"How do I centre a div?"
A memorised Flexbox snippet answers the question but misses the point. Block elements take the full width of their parent; inline elements flow with text. MDN notes that vertical-align only applies to inline, inline-block and table-cell boxes, which is why it does nothing on a block <div>. Setting display: flex or display: grid on the parent changes how its children are laid out, and then alignment properties work.
/* Does nothing: vertical-align doesn't apply to a block box */
.parent { vertical-align: middle; }
/* Works: the parent becomes a grid container */
.parent { display: grid; place-items: center; min-height: 100vh; }
"Why not use divs for everything if we have ARIA?"
Because of the first rule of ARIA use from the W3C: if a native HTML element already has the meaning and behaviour you need, use it instead of adding an ARIA role to something else.
<!-- Avoid: needs tabindex plus click and keydown handlers to work -->
<div role="button" tabindex="0">Save</div>
<!-- Better: focus, Enter and Space work out of the box -->
<button type="button">Save</button>
MDN's page on the button role explains the cost of the first version. The <div> needs tabindex to receive focus, and you must handle click and keydown yourself, including the Enter and Space keys. A native <button> does all of that by default, and assistive technology already knows it.
4. A semantic dashboard boilerplate
Here's a layout for an analytics dashboard that puts the ideas together: landmarks, labelled sections, one <h1>, a skip link and a module script.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Analytics Dashboard</title>
<!-- Render-blocking, so keep it lean -->
<link rel="stylesheet" href="/css/core.css">
<!-- Modules are deferred by default -->
<script type="module" src="/js/dashboard-init.js"></script>
</head>
<body>
<a href="#main-content" class="skip-link">Skip to content</a>
<header class="app-bar">
<nav aria-label="Global">
<!-- Logo and top-level links -->
</nav>
</header>
<div class="dashboard-grid">
<aside class="sidebar-controls">
<nav aria-label="Dashboard filters">
<!-- Sidebar navigation -->
</nav>
</aside>
<main id="main-content">
<header class="view-header">
<h1>Real-time Inference Stats</h1>
<div class="actions">
<button type="button">Refresh</button>
</div>
</header>
<section aria-labelledby="chart-cpu">
<h2 id="chart-cpu">CPU Usage</h2>
<figure>
<!-- Chart canvas -->
<figcaption>Line chart of CPU usage over the last hour</figcaption>
</figure>
</section>
<section aria-labelledby="logs-table">
<h2 id="logs-table">Recent Logs</h2>
<!-- Data table -->
</section>
</main>
</div>
</body>
</html>
Two <nav> elements each get an aria-label, so screen reader users can tell them apart. Each <section> points at its heading with aria-labelledby, which gives it an accessible name.
HTML is the foundation
Choosing block elements and script attributes carefully isn't about passing a quiz. Semantic HTML gives you accessibility, and careful stylesheet and script loading gives you a faster first paint, before you write any JavaScript. In an interview, explain the "why" behind your markup: what the browser builds from it, and what it waits for.
Next in the series, CSS architecture from selectors to BEM styles markup like this without fighting specificity.
Frequently asked questions
What is the difference between article and section?
An <article> is self-contained content that would make sense on its own, such as a blog post or a comment. A <section> is a generic part of a document that has no more specific element, and it should have a heading. If you only need a styling wrapper, MDN says to use a <div>.
Should I use async or defer for my scripts?
Use defer for app code that needs the DOM or depends on other scripts, because deferred scripts run in order after parsing. Use async for independent scripts such as analytics, where order doesn't matter. Module scripts are deferred by default.
Does CSS block HTML parsing?
No. MDN says waiting for CSS doesn't block HTML parsing, but it blocks rendering and holds up scripts. That's why a large stylesheet in the <head> delays First Contentful Paint.
Is it wrong to have more than one h1 on a page?
The HTML standard allows several <h1> elements as long as they aren't nested in sections. MDN still recommends one <h1> per page, followed by headings that don't skip levels.
When is role="button" acceptable?
When you enhance markup by script that you can't replace, or need a role no native element provides. Then you must add tabindex="0" and handle click plus the Enter and Space keys yourself. If you control the HTML, use <button>.
Sources
Verified against the sources below on October 29, 2026. Products and docs change often: check the linked sources if something looks different.
- MDN: The main element
- MDN: The article element
- MDN: The section element
- MDN: Heading elements
- MDN: Accessibility tree (glossary)
- W3C: Using ARIA (first rule of ARIA use)
- MDN: ARIA button role
- MDN: How browsers work
- MDN: Critical rendering path
- MDN: The script element
- MDN: rel=preconnect
- MDN: rel=preload
- web.dev: First Contentful Paint (FCP)
- MDN: vertical-align
All 30 parts in this series
- Part 01Overcoming the Daunting Start: A Strategic Roadmap for New Frontend Developers
- Part 02Beyond the Tags: Mastering HTML Architecture for Product-Based Roles
- Part 03From Selectors to BEM: CSS Concepts You Must Know for Professional Projects
- Part 04Mastering the Primitives: A Builder's Guide to JavaScript Data Types and Functions
- Part 05Demystifying Scope and Closure: Key Concepts for Writing Robust JavaScript
- Part 06Beyond Frameworks: Practical DOM Manipulation Techniques for High-Performance UIs
- Part 07From Prototypes to ES6 Classes: Understanding JavaScript's Object-Oriented Nature
- Part 08Architecting Scalable JavaScript: OOP Principles & Design Patterns
- Part 09Mastering the Metal: Essential Web APIs & Browser Internals for Frontend Engineers
- Part 10Understanding the JavaScript Runtime: Event Loop, Call Stack, and Task Queue Explained
- Part 11Mastering Asynchronous Operations with JavaScript Promises: A Builder's Guide
- Part 12Modern Async Patterns: Making Asynchronous Code Readable with Async/Await and Generators
- Part 13Inside the V8 Engine: A Deep Dive into JavaScript Execution
- Part 14Demystifying CORS, HTTP, and Security: A Builder’s Guide
- Part 15REST vs. GraphQL: A Frontend Engineer’s Reality Check
- Part 16Secure Frontend Auth: The Definitive Guide to JWTs, Cookies, and Storage Strategies
- Part 17Why TypeScript Matters: Adding Type Safety to Your JavaScript Projects
- Part 18Getting Started with React: Deconstructing JSX and Component Architecture
- Part 19React Architecture: Mastering State and Props in Class vs. Functional Components
- Part 20Mastering React Hooks: From useState to Building a Production-Ready Custom Hook
- Part 21React State Management: Context API vs. Redux & Building a Theme Switcher
- Part 22React Architecture: Advanced Navigation and Data Flow Patterns
- Part 23Automated Testing in React: Unit Testing with Jest and React Testing Library
- Part 24Mastering Chrome DevTools: Debugging Techniques That Save Hours of Development Time
- Part 25Automating Code Quality: The Modern Stack with ESLint, Prettier, and Husky
- Part 26Demystifying the Build Pipeline: A Deep Dive into Webpack and Babel Configuration
- Part 27Improving Performance with Server-Side Rendering: Concepts and Implementation
- Part 28From Development to Production: A Builder's Guide to Frontend Deployment Strategies
- Part 29Introduction to Micro Frontends: Building Scalable Architectures
- Part 30The Frontend Architecture: From Junior Developer to Tech Lead



Comments
Loading comments...