🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: CSS Basics: all 10 questions

Quiz: CSS Basics · Question 3 of 10

Two rules: .title { color: red } and main { color: blue } both match an element. Which colour wins?

Two rules: .title { color: red } and #main { color: blue } both match an element. Which colour wins?

  1. A.red
  2. B.blue
  3. C.whichever is written later
  4. D.black
Answer & explanation

Correct answer: blue

An id selector has higher specificity than a class.

Can you get the rest right without peeking?

Take the timed Quiz: CSS Basics quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →