Skip to content
Tech Interview Prep
Technical interview guideNew

DOM and Browser Rendering

How the browser turns HTML, CSS and JavaScript into pixels: the critical rendering path, style/layout/paint/composite, what reflow and repaint actually cost, event propagation, and semantic HTML. These decide both whether a page is correct and how fast it feels.

Read
16 min
Practice MCQs
25
Interview Q&A
25
Edition
v1
Editorial status
Reviewed
Relevant for
Frontend Engineer

Scope: Current to the WHATWG HTML Living Standard and the CSSOM/Event specs; rendering-pipeline behaviour described is Chromium's as documented on web.dev and chromium.org, with Gecko and WebKit differences called out where they change the answer. Checked against Chrome 131, Firefox 133, Safari 18..

Curated: · Written: · Reviewed:

25 questions

MCQ-13A page's body holds `<table><tr><div id="note">N</div><td id="cell">C</td></tr></table>` as its only content. Which account of the DOM the parser builds from that source is right?
MCQ-4A page's `<head>` holds a `<style>` element whose only rule is `p::before { content: "*" }`; the body holds `<div id="a" style="display:none">`, `<div id="b" style="visibility:hidden">` and `<p id="c">`. Which nodes does the render tree hold?
MCQ-3A page's `<head>` links three stylesheets: `base.css` with no `media` attribute, `print.css` with `media="print"`, and `wide.css` with `media="(min-width: 1200px)"`. The page is opened in a 1024×768 desktop window; `base.css` takes 90 ms to arrive, `print.css` 400 ms and `wide.css` 150 ms. Which account of the first paint is right?
MCQ-14An internal dashboard has a `Dump state` button whose click handler ends with `document.write('<pre>' + JSON.stringify(state) + '</pre>')`; the page finished loading ten minutes ago and the user clicks it. Which account of what the browser does with that call is right?
MCQ-1A page's `<head>` holds a synchronous `<script src="app.js">` (300 KB: 300 ms to fetch, 100 ms to execute) immediately followed by `<link rel="stylesheet" href="theme.css">` (120 ms to fetch), and the body below carries the above-the-fold content. Which resource gates first paint, and why?
MCQ-2A page's head contains `<script defer src="a.js">` followed by `<script async src="b.js">`. HTML parsing finishes at 300 ms. Neither file is cached: a.js finishes downloading at 2.0 s and b.js at 1.5 s. In what order do the scripts execute, and when does DOMContentLoaded fire?
MCQ-15A page's inline script runs during parsing and injects three external scripts in the order a.js, b.js, c.js: each one built with `document.createElement('script')`, given `src`, given `async = false`, and then appended to `document.head`; a.js takes 2.0 s to download, b.js 0.2 s and c.js 1.0 s, and each file logs its own name the moment it executes. Which account of the three logs is right?
MCQ-23A page's `<head>` contains one resource hint and no other reference to the stylesheet: `<link rel="preload" as="style" href="/theme.css">`. The HTML is 6 KB and arrives at 60 ms; theme.css is 40 KB and takes 200 ms to fetch; the heading and paragraph in the body are above the fold. Which account of what the user sees is right?
MCQ-8A menu is built as `<ul id=menu><li><span class=label>Docs</span></li></ul>`. One click listener is registered on `#menu`; nothing is registered on the `li` or the `span`. A user clicks the text inside the span, and the handler logs `event.target.tagName` and `event.currentTarget.tagName`. Which pair does it log?
MCQ-7A page has three nested divs, `#outer` > `#middle` > `#inner`, with `document` above them. Each of those four nodes has one `click` listener registered with `capture: true` and one without, each logging a label such as `outer-capture` or `outer-bubble`; on every node the capture listener is registered first. A user clicks the text inside `#inner`. Which sequence of labels does the console print?
MCQ-9A 200-row list renders each row as `<li><a class="row" href="/items/42">Row 42</a></li>`. One delegated listener on the `<ul>` checks `event.target.closest('a.row')`; on a match it calls `event.preventDefault()`, then `history.pushState({}, '', '/items/42')` and re-renders the panel. A user clicks a row link. Which account of that click is right?
MCQ-10A carousel adds `document.addEventListener('touchstart', e => e.preventDefault())` to stop the page scrolling under a horizontal drag. On Chrome for Android the page still scrolls during the drag, and DevTools logs `Unable to preventDefault inside passive event listener invocation.` Which account of that log and fix is right?
MCQ-11A team ships a custom mute toggle as `<div role="button" tabindex="0" onclick="toggle()">Mute</div>`. A keyboard-only tester can Tab to it, and a screen reader announces 'Mute, button'. Which account of what still fails is right?
MCQ-12A collapsed sidebar is parked off-screen with `transform: translateX(-100%)` and its `<aside>` carries `aria-hidden="true"`; the aside still contains `<a href="/settings">Settings</a>`. A keyboard user tabs through the page. Which account of that link is right?
MCQ-5A drag-to-dismiss card is animated by a requestAnimationFrame loop that writes one new position per frame on a mid-range Android phone. Variant A writes `el.style.transform = 'translateX(' + x + 'px)'`; variant B writes `el.style.left = x + 'px'` on the same `position: absolute` element, and nothing else on the page changes. Which account of the per-frame work each variant forces is right?
MCQ-21A product card lifts on hover. Variant A animates `box-shadow` from `0 2px 4px rgba(0,0,0,.2)` to `0 12px 24px rgba(0,0,0,.4)` over 300 ms; variant B keeps the large shadow on an `::after` pseudo-element and animates that layer's `opacity` from 0 to 1 over the same 300 ms. The card's geometry never changes, and both run on a mid-range Android phone. Which account of the per-frame work is right?
MCQ-6A resize handler loops 300 times over one panel: each iteration sets `panel.style.width = widths[i] + 'px'` from a precomputed array and then reads `panel.offsetHeight` into a heights array. The Performance panel shows 300 Layout entries totalling 410 ms and the handler misses frames. Which account of that cost, and which change, is right?
MCQ-22A framework re-renders a 10,000-row list on every keystroke of a filter box. Diffing one virtual node costs 15 µs and writing one row's text node costs 1.2 µs. A keystroke changes the match state of 12 rows. Which account of the frame's dominant cost is right?
MCQ-19A team sees a field INP of 210 ms on a product grid and blames the `scroll` listener, which runs one 200 ms synchronous task, a `getBoundingClientRect` loop that repositions a sticky header, during a flick on a mid-range Android phone; the flick also drops about a dozen frames. Which account of the damage and its attribution is right?
MCQ-16A category page renders 24 cards in a CSS grid; each is `<img src="p.jpg" style="width:100%;height:auto">` with no `width`/`height` and no `aspect-ratio`. On a Moto G4 over 4G the HTML paints at 1.2 s with every image box 0 px tall; the 240×320 JPEGs land between 1.9 s and 2.4 s, each grid row grows 320 px, and the footer moves down. Captions swap to a webfont at 2.1 s. Field CLS is 0.28, LCP 2.4 s. Which account of what the missing attributes cost is right?
MCQ-20A 40-section article page sets `content-visibility: auto` on every `<section>` and nothing else; each section lays out about 800 px tall and the viewport is 800 px. At load the document measures about 1,600 px and the scrollbar thumb fills half the track; after the reader scrolls to the footer it measures about 32,000 px and the thumb is a sliver. Which account of that growth is right?
MCQ-18A product card is `<div class="card">` with `height: auto`, holding a 200 px image and three lines of text, and it measures 260 px tall. A developer adds `contain: strict` to `.card` to isolate its layout; the card now measures 0 px tall and nothing inside it is visible, though the DOM still holds the image and the text nodes. Which account of that result is right?
MCQ-17A 500-row list renders each row as a 320×80 px `<li>`, and to smooth scrolling on a mid-range Android phone at device pixel ratio 2 the team adds `will-change: transform` to every row. The scroll is smooth for a moment, then gets worse than before and Chrome's GPU process reports the compositor over its memory budget. Which account of that cost is right?
MCQ-24A product page streams with React 18's `renderToPipeableStream`: the shell (header, gallery, price) flushes at 200 ms, a `<Suspense fallback={<ReviewsSkeleton/>}>` wraps the reviews, the reviews data resolves at 1.8 s and the server then flushes 40 KB of review markup, and the reviews' 30 KB client chunk arrives at 2.2 s. Which account of what the browser does with the reviews between 1.8 s and 2.5 s is right?
MCQ-25An e-commerce site serves 5,000 product pages from one template. A shared `app.css` is 180 KB uncompressed (45 KB gzipped), changes about once a week, and is served from the CDN with a content-hashed filename and a one-year cache lifetime; each HTML document is 14 KB and is cached for five minutes. To remove the render-blocking stylesheet request, the team proposes inlining the full `app.css` into the `<head>` of every page. Which account of that trade-off is right?