Using tags that describe meaning: <nav>, <header>, <main>, <article>, <button>, not <div> for everything. Screen readers, search engines and browsers understand the page better, and a real <button> works with the keyboard for free.
Say it like this in the interview
“Semantic elements describe the role of content. They improve accessibility because screen readers announce landmarks and controls correctly, improve SEO, and give built-in behaviour: a <button> is focusable and responds to Enter and Space; a clickable <div> isn’t.”
Search engines read your title, description, headings, links and image alt text to understand the page.
Say it like this in the interview
“A unique <title> and meta description, a single clear <h1> with a logical heading hierarchy, a canonical link, descriptive link text, alt on images, structured data, semantic elements, and fast loading.”
By default (content-box) width means only the content. Padding and border are added outside it: 200 + 20×2 + 5×2 = 250. With box-sizing: border-box the width includes padding and border, so it stays 200px, which is why most projects set it globally.
Say it like this in the interview
“250px: content 200 plus 40 padding plus 10 border, because the default box-sizing is content-box. With border-box it would be exactly 200px.”
Flexbox = one direction (a row of buttons, a navbar): items flow and share space. Grid = two directions (rows and columns, like a page layout or a card gallery).
“Flexbox for one-dimensional alignment where content size drives layout, like toolbars. Grid for two-dimensional layouts where I define the structure, like page layouts and card galleries. I often combine them: grid for the page, flex inside components.”
z-index only competes inside the same stacking context, like floors inside one building. If the dropdown’s parent building is lower, even the top floor of it is below the next building. transform, opacity < 1, filter and position with a z-index create new buildings.
Say it like this in the interview
“A parent creates a stacking context, through transform, opacity, filter, will-change or a positioned element with z-index, and the dropdown can’t escape it. Fixes: raise the parent’s z-index, remove the property creating the context, or render the dropdown in a portal at the body level. Also z-index needs a positioned element or a flex/grid child to apply.”
relative: normal place, but can be nudged; becomes the anchor for absolute children.
absolute: taken out of flow, placed relative to the nearest positioned ancestor.
fixed: stuck to the screen.
sticky: scrolls normally until it hits a point, then sticks.
Say it like this in the interview
“Static is the default flow; relative offsets from its own position and creates a containing block; absolute positions against the nearest non-static ancestor; fixed against the viewport; sticky toggles between relative and fixed within its scroll container.”
“display: grid; place-items: center on the parent, or Flexbox with justify-content and align-items: center. For absolutely positioned elements, inset: 0; margin: auto with a set size.”
Vertical margins between blocks merge into the larger one. It’s called margin collapsing.
Say it like this in the interview
“Adjacent vertical margins collapse to the larger value, also between parent and first child. It doesn’t happen in flex or grid containers or with padding and borders in between. Using gap in flex or grid avoids the confusion.”
CSS has a points system: IDs beat classes beat tags. #header .btn has one ID, so it beats any number of classes. Order only matters when the score is a tie.
Say it like this in the interview
“Specificity: #header .btn is (1,1,0), .btn.primary is (0,2,0). The ID wins regardless of order. I’d avoid ID selectors for styling, or use :where() to lower specificity or cascade layers. !important is a last resort.”
Specificity counts IDs, then classes, then elements. One ID beats any number of classes.
Say it like this in the interview
“Green, from #intro, specificity (1,0,0). Then .lead.text (0,2,0), then p (0,0,1). Inline styles beat all, and !important overrides normal declarations.”
Pseudo-classes describe a state (:hover, :focus, :first-child). Pseudo-elements style a part of an element or add content (::before, ::after, ::placeholder).
Say it like this in the interview
“Single colon for pseudo-classes like :hover, :focus-visible, :nth-child or :has(); double colon for pseudo-elements like ::before, ::after or ::selection. :has() acts as a parent selector.”
Mobile-first means write the simple phone layout as the default, then add min-width media queries to enhance it for bigger screens. Mobile CSS stays light.
“The viewport meta tag, fluid layouts with grid and flex, relative units and clamp(), responsive images with srcset, and mobile-first min-width media queries. For components I use container queries so they adapt to their container, not the screen.”
px is fixed. rem scales with the root font size (respects user settings). em scales with the parent’s font size. % is relative to the parent. vw/vh are percentages of the screen.
Say it like this in the interview
“rem for font sizes and spacing for accessibility; em for component-relative spacing; percentages and fr for layout; viewport units for full-screen sections (with dvh on mobile); px for borders.”
Someone using only a keyboard or a screen reader must be able to know the modal opened, use it, and close it, without getting lost behind it.
Say it like this in the interview
“Use the native <dialog> element with showModal(), or replicate it: role=dialog, aria-modal, a label via aria-labelledby; move focus into it on open; trap focus inside; close with Escape; return focus to the trigger on close; and make the background inert. Plus visible focus styles and sufficient colour contrast.”
Every input needs a visible label, errors need to be clear and announced, and everything must work with a keyboard.
Say it like this in the interview
“<label for> tied to each input, correct input types and autocomplete, grouping with fieldset and legend, error messages linked with aria-describedby and announced, not relying on colour alone, and a logical tab order.”
Things arrive late and push other things down: images without a reserved size, ads, web fonts swapping, banners injected at the top.
Say it like this in the interview
“Layout shift comes from elements without reserved space. I set width/height or aspect-ratio on images and embeds, reserve space for ads and banners, use font-display: optional or size-adjusted fallback fonts, and avoid inserting content above existing content except in response to user input.”
Changing size or position properties makes the browser recalculate layout (slow). transform and opacity can be animated on the GPU without re-layout.
Say it like this in the interview
“Animate transform and opacity, which are composited; avoid animating width, top or margin, which trigger layout and paint. Use will-change sparingly and respect prefers-reduced-motion.”