ProAdvancedInterview prep

CSS Advanced

Containing blocks, stacking contexts, block formatting contexts and the genuinely surprising cases of margin collapsing. Then cascade layers, :is and :where, and what happens to a custom property that is invalid at computed-value time.

Questions90
Topics10
Answering time68 minutes
At five a day18 days
LevelAdvanced

Who it is for

Confident; wants the traps.

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

    Containing Blocks

    Find the box an element's offsets and percentages are measured against, and name what established it.

  2. 02

    Stacking Contexts In Full

    List what creates a stacking context and work out which of two boxes paints on top.

  3. 03

    Block Formatting Contexts

    Say what a block formatting context changes about floats, margins and overlap, and which declarations start one.

  4. 04

    Margin Collapsing

    Predict when two margins become one, including through a parent, and name the declaration that stops it.

  5. 05

    Replaced Element Sizing

    Explain how an image sizes itself from its intrinsic dimensions, attributes and CSS together.

  6. 06

    Intrinsic & Extrinsic Sizing

    Choose between a size the box is given and a size the box works out from its own content.

  7. 07

    Cascade Layers

    Predict which declaration wins once layers are in play, including when !important is involved.

  8. 08

    Selector Functions & Specificity

    Compute the specificity of :is, :where, :not and :has, and use them to hold it down.

  9. 09

    Custom Properties & Invalid Values

    Predict what a var() resolves to, when the fallback is used, and what happens when substitution fails.

  10. 10

    Containment & Discrete Transitions

    Say what each containment value promises the engine, and transition a property that has no in-between.

8 more topics, and all 90 questions

CSS Advanced 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

Containing Blocks

The button was fixed to the viewport, and now it scrolls away with the panel. Why?

<style>
  .panel { transform: translateZ(0); }
  .fab   { position: fixed; bottom: 0; }
</style>
<div class="panel">
  <button class="fab">Add</button>
</div>
  • ABecause a transform on an ancestor makes that ancestor the containing block for fixed descendants
  • BBecause translateZ(0) promotes the subtree to its own compositing layer, and layers scroll together
  • CBecause position: fixed is only honoured on direct children of the body
  • DBecause bottom: 0 is ignored on a fixed element that has no height
Show the answer

A Because a transform on an ancestor makes that ancestor the containing block for fixed descendants

The compositing explanation is the popular one and it is about painting, not layout - a layer promotion on its own never changes what a percentage or an offset is measured from. The containing block rule is the real one, and it is why will-change: transform on a wrapper can break a fixed header three components away. filter and contain do the same thing.

The rest of the track

CSS at every depth

Start CSS Advanced
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