Tricky CSS Questions

This CSS quiz is for people who think they know CSS well. It covers the behaviors that surprise even experienced developers: stacking contexts, margin collapsing through parents, percentage padding, :is() specificity, sticky elements that will not stick and flex items that will not shrink.

Difficile 10 questions ~8 minutes Réussi à partir de 80 %

Choisissez un mode

Vous jouez en invité : connectez-vous pour garder votre XP et votre série.

Exemple de question

Question 1 sur 10

.child and .b overlap. Which one is drawn on top?

<style>
  .a { position: relative; z-index: 1; }
  .child { position: relative; z-index: 9999; }
  .b { position: relative; z-index: 2; }
</style>
<div class="a"><div class="child">child</div></div>
<div class="b">b</div>
Voir la réponse

D. .b, because .child is trapped inside .a's stacking context .a with position and z-index creates a stacking context, and .child's 9999 only counts inside it. At the outer level .a (1) is compared with .b (2), so .b and everything in it wins.

Ce que couvre ce quiz

  • Stacking contexts and why z-index: 9999 can lose
  • Margins that escape their parent and percentage padding
  • Specificity of :is() and exact attribute selectors
  • position: sticky and position: fixed surprises
  • Inline-block whitespace, 100vh on mobile and flex min-width

Questions fréquentes

Faut-il un compte ?

Non. Tout le monde peut jouer. Connectez-vous pour garder votre XP, votre série, vos badges et votre historique.

Puis-je le refaire ?

Oui. Votre meilleur score est conservé, et les questions comme les réponses sont mélangées à chaque fois.