HTML & CSS Senior interview questions and answers
75 questions for a HTML & CSS (Senior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.How do
@layercascade layers affect style priority? - 2.How do normal (non-
!important) layered and unlayered styles rank against each other? - 3.What does
@scope (.card) to (.card__content) { img { ... } }do? - 4.What problem does
subgridsolve? - 5.Which stages does the browser go through to update a frame after a style change?
- 6.What is layout thrashing (forced synchronous layout)?
- 7.What does
contain: layout paint(orcontain: content) give you? - 8.How does
content-visibility: autospeed up long pages? - 9.Why don't
::beforeand::afterwork on<img>and<input>? - 10.What is
floatstill appropriate for in modern layouts? - 11.Why is
emoften recommended overpxfor media query breakpoints? - 12.What happens to a
position: fixedelement if an ancestor hastransform: translateZ(0)? - 13.How does
overflow: clipdiffer fromoverflow: hidden? - 14.How should Sass modules be included now that
@importis deprecated? - 15.How does Dart Sass differ from Node Sass?
- 16.What problems does runtime CSS-in-JS (styled-components, Emotion) have with SSR and React Server Components?
- 17.Which techniques reduce the weight and performance impact of a custom web font?
- 18.How does asset bundling strategy change when moving from HTTP/1.1 to HTTP/2+?
- 19.What is a performance budget?
- 20.How does lab data (Lighthouse) differ from field data (CrUX, RUM)?
- 21.Which three metrics make up Core Web Vitals today?
- 22.How do you build a horizontal gallery with slides that "snap" into place without JavaScript?
- 23.What does
@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }enable? - 24.How do you style the inside of a Web Component when Shadow DOM isolates its styles?
- 25.How do
min-content,max-contentandfit-contentdiffer as width values? - 26.What creates a new stacking context even without
positionandz-index? - 27.What conditions make the vertical margins of a parent and its first child collapse?
- 28.Why can a long word or a wide table "blow out" a
1frgrid column? - 29.Why is
oklch()more convenient thanhsl()for design systems? - 30.What is
color-mix(in oklch, var(--brand) 80%, white)for? - 31.What does native CSS nesting (
&) give you? - 32.What is CSS Anchor Positioning used for?
- 33.What is the View Transitions API?
- 34.What is the minimum required for an accessible modal dialog?
- 35.What does the
inertattribute do? - 36.What minimum text contrast does WCAG level AA require for normal text?
- 37.How do WCAG conformance levels A, AA and AAA differ?
- 38.When are ARIA attributes needed, and when is it better to do without them?
- 39.What does
text-wrap: balancedo on a heading? - 40.What are HTML landmarks, and why do they matter?
- 41.Which accessibility problem is typical for SPAs when the "page" changes on the client?
- 42.How does Tailwind v4 fundamentally differ from v3?
- 43.How do you make Tailwind v4's dark mode follow a
.darkclass instead of the system setting? - 44.You're designing the CSS architecture of a multilingual site including Arabic (RTL) and Japanese. What should you plan for?
- 45.Which approach to fluid typography best respects the user's font scaling?
- 46.A 10,000-row table lags when scrolling. Which solution is most effective?
- 47.A gallery with 50 YouTube videos loads very slowly. What should you do first?
- 48.How does
preloaddiffer fromprefetchin<link rel>? - 49.How does
deferdiffer fromasyncon<script>? - 50.A designer insists on fully custom styles for every control in a complex form. What's a sensible approach?
- 51.What does
font-size: 5cqimean inside a container query? - 52.Why style errors with
:user-invalidinstead of:invalid? - 53.What does the
popoverattribute give you? - 54.What problem does
@starting-stylesolve? - 55.What do scroll-driven animations (
animation-timeline: scroll()) allow? - 56.What does
color: light-dark(#111, #eee)do? - 57.What does
hyphens: autoneed to work correctly? - 58.Why use
font-variant-numeric: tabular-numsin tables and timers? - 59.What is the main advantage of a variable font?
- 60.How does
size-adjustin a fallback@font-facereduce layout shift? - 61.What does
fetchpriority="high"on the hero image do? - 62.Why add
isolation: isolateto a component root? - 63.What does
overscroll-behavior: containon a scrollable modal body prevent? - 64.What layout shift does
scrollbar-gutter: stableprevent? - 65.What happens to your colors in Windows High Contrast (forced colors) mode?
- 66.What is a skip link?
- 67.How do you correctly associate an error message with an input?
- 68.What does the WCAG "Reflow" criterion require?
- 69.What does WCAG 2.2 "Target Size (Minimum)" ask for?
- 70.Why do build tools emit CSS files with content hashes (
app.3f9a1c.css)? - 71.Why split design tokens into primitive and semantic layers?
- 72.Why use
dir="auto"on user-generated content such as comments? - 73.Why prefer
IntersectionObserveroverscrolllisteners for lazy loading or reveal effects? - 74.Why avoid
@importinside plain CSS files? - 75.What does
li:nth-child(2 of .visible)select?