Markup & Styling
HTML, the CSS language and the tools that compile, transform or scope it, plus JSX, MDX and server templates. Interviewers start here because styling choices outlive the frameworks around them.
on this pageshowhide
explore
- HTML (has its own guide)174 questions
- Document Structure26 questions
- Semantic Elements31 questions
- Forms and Inputs32 questions
- Accessibility and ARIA30 questions
- Metadata and SEO26 questions
- Media and Embedding29 questions
- JSXempty
- MDXempty
- CSS (has its own guide)240 questions
- Selectors and Specificity43 questions
- Box Model and Flow30 questions
- Flexbox Layout28 questions
- Grid Layout29 questions
- Responsive Design26 questions
- Custom Properties and Animations31 questions
- Positioning and Stacking26 questions
- CSS Architecture27 questions
- Stylesheet Toolingempty
- Sassempty
- PostCSSempty
- CSS Modulesempty
- CSS-in-JSempty
- Panda CSSempty
- Tailwind CSSempty
- EJSempty
- Pugempty
- Razorempty
→ has its own guide
questions
414 · 2 sectionsIn HTML and ARIA, what is an element's accessible name, and what does the browser compute it from for `<button>Save</button>` and `<img src="logo.png" alt="Acme home">`?
basics
~20 sAn element's accessible name is the short label assistive technology announces for it. The browser computes it per element type: a button's name comes from its own text content, an image's from its alt attribute.
In HTML, what do tabindex="0", tabindex="-1", and a positive value such as tabindex="3" each do to an element?
basics
~20 stabindex="0" puts an element in the tab order at its DOM position; a negative value such as -1 makes it focusable by script or click but never by Tab; a positive value jumps it ahead of everything else and wrecks the order.
A toolbar button in your HTML contains only an <svg> icon and no text. What are your options for giving it an accessible name, and which would you choose?
basics
~20 sGive the button an accessible name with aria-label="Delete", with visually hidden real text inside it, or with aria-labelledby pointing at existing on-screen text. Hide the decorative icon with aria-hidden="true" so it adds nothing. A title tooltip alone is not enough.
In ARIA, what is the difference between aria-live="polite" and aria-live="assertive" on a live region, and which of the two do role="status" and role="alert" imply?
basics
~10 saria-live="polite" queues the announcement until the screen reader finishes what it is saying; aria-live="assertive" interrupts immediately. role="status" implies polite, role="alert" implies assertive, and both imply aria-atomic="true".
In web accessibility, the "first rule of ARIA use" is quoted constantly in interviews. What does the rule say, and what does following it look like in real markup?
basics
~20 sThe first rule of ARIA is to not use ARIA when a native HTML element already provides the semantics and behaviour you need. Reach for button, a with href, input and label first; add ARIA only to fill real gaps.
In the BEM CSS naming methodology, what do "block", "element" and "modifier" mean, and how does each one appear in a class name?
basics
~10 sBEM names classes after a block (a standalone component, .card), its elements (parts that exist only inside it, .card__title), and modifiers (variant flags, .card--featured). Two underscores mark an element, two hyphens mark a modifier.
In CSS, why is a class rule such as .title { color: red } described as living in a global namespace, and what problems does that create in a large codebase?
basics
~20 sCSS selectors are matched against the entire document regardless of which file they were written in, so one .title rule styles every element with that class. Collisions are silent, and unrelated components end up restyling each other.
Most CSS style guides tell you to style a component with a single class like `.card__title` instead of a chain like `#main .card h2`. Both match the same heading — what does the flat single-class convention buy a growing codebase?
basics
~20 sA single class keeps every rule at the same low weight, so a later rule can override it by source order alone. IDs and long descendant chains raise the weight, forcing every future override to be heavier still.
In CSS architecture, what does a "utility-first" approach mean compared with writing semantic component classes, and what trade do the two make against each other?
basics
~20 sUtility-first composes many single-purpose classes in the markup, each setting one or two declarations. The semantic approach puts one meaning-based class on the element and defines all its styling in the stylesheet. The trade is markup noise versus an ever-growing stylesheet.
In CSS, an element has `width: 100px`, `padding: 20px`, and `border: 2px solid`. How wide does it actually render under the default `box-sizing`, and what changes if you set `box-sizing: border-box`?
basics
~20 sUnder the default box-sizing: content-box, width sizes only the content box, so 100px width plus 20px padding on each side plus 2px borders renders 144px wide. With box-sizing: border-box the box stays 100px and the content area shrinks to 56px.