ProAdvancedInterview prep

CSS Interview Questions

Specificity arithmetic, the cascade in full, box-sizing, centring in every mechanism, and flexbox against grid. Ten topics built around the questions that get asked out loud and the "what colour is this, and why" that follows.

Questions90
Topics10
Answering time68 minutes
At five a day18 days
LevelAdvanced

Who it is for

Preparing, and short of time.

For someone confident in the language who wants the traps, the edge cases and the interview questions.

You will get the most out of it if you have written CSS recently enough to read it without effort, and have been surprised by it at least once. If you are picking the language up for the first time, start with CSS Essentials and come back to this one.

It is also built for interview preparation: the questions are the ones that get asked because they separate people who have read the documentation from people who have hit the behaviour in production.

How long it takes

90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.

At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.

A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.

Question mix

  • 60 multiple choice
  • 10 concept cards
  • 10 predict the output
  • 10 put it in order
  • 10 matching questions

Syllabus

What you will be asked about

  1. 01

    Specificity Arithmetic

    Count a selector's specificity and say which of two rules wins, including the modern pseudo-classes.

  2. 02

    The Cascade In Full

    Walk the cascade in order - origin, importance, layers, specificity, appearance - and predict the winner.

  3. 03

    Box Model And box-sizing

    Work out what a declared width includes, and where padding and margins actually land.

  4. 04

    Centring, Every Mechanism

    Pick the right centring mechanism for a given box, and say why the familiar one is failing.

  5. 05

    Flexbox Versus Grid

    Choose between flexbox and grid for a given layout, and read the flex shorthand correctly.

  6. 06

    Position And Stacking

    Find an element's containing block and say which declarations create a stacking context.

  7. 07

    Responsive Strategies

    Choose between media queries, container queries and intrinsic sizing, and justify the choice.

  8. 08

    Inheritance And The Global Keywords

    Say which properties inherit and what inherit, initial, unset and revert each do.

  9. 09

    Pseudo-Classes And Pseudo-Elements

    Tell a pseudo-class from a pseudo-element and predict what each one selects.

  10. 10

    What Colour Is This, And Why

    Resolve a colour through matching, the cascade, inheritance and shorthand side effects.

8 more topics, and all 90 questions

CSS Interview Questions is a Pro course. One subscription opens it and every other course in the catalogue, including the ones still being written.

See pricing Find a free course

A question from this course

Specificity Arithmetic

Which colour wins?

<style>
  #save { color: red; }
  .a.b.c.d.e.f.g.h.i.j.k { color: blue; }
</style>
<p id="save" class="a b c d e f g h i j k">Go</p>
  • ARed: one id is `1,0,0` and beats any number of classes
  • BBlue: eleven classes outweigh a single id
  • CBlue: the later rule wins because the specificities are close
  • DRed, but only because the id selector appears first
Show the answer

A Red: one id is `1,0,0` and beats any number of classes

The instinct that enough classes must eventually add up to an id is the single most common specificity error. The columns are compared left to right and never carry, so 0,11,1 loses to 1,0,0 on the first comparison - and adding a twelfth class changes nothing.

The rest of the track

CSS at every depth

Start CSS Interview Questions
in tomorrow’s session.

Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.

Browse the catalogue