CSS MCQ Test
20 random CSS multiple-choice questions with answers: selectors, specificity, the box model, colours, units, Flexbox, Grid, positioning and responsive design.
- 20 random questions
- 20 minutes
- 60 in the question bank
No sign-up needed. Answers and explanations are shown at the end.
About this test
CSS questions look easy until two rules fight each other. This test focuses on what decides the result: specificity, the box model, units, display and positioning.
You will also get Flexbox, Grid and media-query questions, the topics interviewers use to check whether you can build a real layout.
Each attempt picks new questions at random from the question bank. You can go back and change answers until you finish or the timer runs out. At the end you see your score, the right answer and a short explanation for every question, and the lessons to revise for the ones you missed.
Topics covered
- CSS Introduction
- How to Add CSS
- CSS Selectors
- CSS Colors
- CSS Backgrounds
- CSS Borders
- CSS Margin and Padding
- CSS Box Model
- CSS Width and Height
- CSS Text and Fonts
- CSS Display
- CSS Position
- CSS Flexbox Basics
- CSS Flexbox Layouts
- CSS Grid Basics
- CSS Grid Layouts
- CSS Responsive Design and Media Queries
- CSS Transitions and Transforms
- CSS Variables
- CSS Project: Style Your Profile Page
Sample questions with answers
1. In p { color: blue; }, what is p?
- The selector
- The value
- The property
Show answer
A. The selector — color is the property, blue the value.
2. What is the normal way to add CSS to a website?
- A
<css>tag - Inline style attributes everywhere
- An external stylesheet linked with
<link rel="stylesheet">
Show answer
C. An external stylesheet linked with <link rel="stylesheet"> — One file styles every page.
3. Which selector matches elements with class="card"?
card.card#card
Show answer
B. .card — # is for ids.
4. Which is a valid hex colour?
#0a7d4f0a7d4f##zz1122
Show answer
A. #0a7d4f — Hex uses 0-9 and a-f.
5. Which background-size fills the box completely, cropping if needed?
- contain
- auto
- cover
Show answer
C. cover — contain shows the whole image without cropping.
6. Which makes a perfect circle from a square?
shape: circleborder-radius: 50%border-radius: circle
Show answer
B. border-radius: 50% — Works when width equals height.
7. Padding vs margin?
- They're the same
- Padding is inside the border; margin is outside
- Margin is inside
Show answer
B. Padding is inside the border; margin is outside — Padding gets the background colour.
8. With default box-sizing, a 300px-wide box with 20px padding and 5px border is how wide?
- 300px
- 325px
- 350px
Show answer
C. 350px — Content-box adds padding and border to the width.
9. Which is best for responsive images and containers?
max-width: 100%height: 100%width: 1200px
Show answer
A. max-width: 100% — They shrink on small screens but don't grow too large.
10. Why list fallbacks in font-family?
- If the first font is unavailable, the next one is used
- For SEO
- To use all fonts at once
Show answer
A. If the first font is unavailable, the next one is used — End with a generic family like sans-serif.