Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 11.8 — CSS Interview Questions
CSS · Example 1 of 4

Specificity duel

One ID (1,1,0) beats any number of classes, so crimson wins although three rules come later. An inline style beats every selector.

The CSS questions interviewers ask most (specificity, the box model, Flexbox vs Grid, positioning and block formatting contexts) each have a short, precise model answer; learn the answer, the example that proves it, and the follow-up they usually ask next.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Order these selectors from weakest to strongest: ul li a, .menu a, #top a, :where(#top) a.link, a:hover.

02

A box has width: 300px; padding: 16px; border: 2px solid; margin: 10px; with default box-sizing. How wide is it on screen, and how much horizontal space does it take including margins? What changes with border-box?

03

Write CSS to place a close button in the top-right corner of a .modal, 8px from each edge.

Explain it without notes

01

How is CSS specificity calculated? Give examples, including :is(), :where() and inline styles.

02

Explain the CSS box model and the difference between content-box and border-box.

03

When would you use Flexbox and when Grid?

04

Explain the values of position and what the containing block is for each.

05

What is a block formatting context, how do you create one, and what problems does it solve?

Specificity duel

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

winner: rgb(220, 20, 60)
after an inline style: rgb(128, 0, 128)