← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 510 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  2. 2.⚖️ What colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    h1 { color: purple; }
    .big { color: red; }
    #hero { color: green; }
    (a) green (b) red (c) purple (d) black
  3. 3.⚖️ What colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    #hero { color: yellow; }
    #hero { color: white; }
    (a) white (b) red (c) black (d) yellow
  4. 4.⚖️ What colour is the text of this element?
    <p class="big" id="top">Hi</p>
    CSS:
    .big { color: white; }
    #top { color: red; }
    p { color: purple; }
    (a) purple (b) white (c) red (d) black
  5. 5.⚖️ What colour is the text of this element?
    <h1 class="box" id="logo">Hi</h1>
    CSS:
    .box { color: blue; }
    .box { color: purple; }
    (a) yellow (b) blue (c) black (d) purple
  6. 6.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    p { color: orange; }
    .menu { color: black; }
    #hero { color: white; }
    (a) black (b) orange (c) yellow (d) white
  7. 7.⚖️ What colour is the text of this element?
    <p class="box" id="logo">Hi</p>
    CSS:
    .box { color: white; }
    .box { color: red; }
    (a) blue (b) red (c) yellow (d) white
  8. 8.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    #top { color: black; }
    .box { color: orange; }
    (a) green (b) orange (c) black (d) white
  9. 9.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: purple; }
    .big { color: red; }
    (a) yellow (b) red (c) purple (d) black
  10. 10.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the later one (c) neither (d) the shorter one
  11. 11.⚖️ What colour is the text of this element?
    <p class="menu" id="logo">Hi</p>
    CSS:
    #logo { color: green; }
    #logo { color: blue; }
    (a) blue (b) green (c) red (d) orange
  12. 12.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    .note { color: yellow; }
    #main { color: green; }
    (a) yellow (b) blue (c) red (d) green
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="big" id="hero">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: red; }
    (a) red (b) black (c) orange (d) green
  14. 14.⚖️ What colour is the text of this element?
    <p class="menu" id="logo">Hi</p>
    CSS:
    p { color: blue; }
    p { color: yellow; }
    (a) purple (b) white (c) yellow (d) blue
  15. 15.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    p { color: white; }
    p { color: green; }
    (a) red (b) orange (c) white (d) green
  16. 16.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    #logo { color: black; }
    p { color: purple; }
    (a) black (b) purple (c) yellow (d) green
  17. 17.⚖️ What colour is the text of this element?
    <h2 class="menu" id="top">Hi</h2>
    CSS:
    .menu { color: white; }
    h2 { color: yellow; }
    (a) white (b) green (c) red (d) yellow
  18. 18.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  19. 19.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: blue; }
    .big { color: white; }
    (a) green (b) blue (c) white (d) black
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    h2 { color: orange; }
    .box { color: white; }
    (a) orange (b) white (c) green (d) purple
  21. 21.⚖️ What colour is the text of this element?
    <p class="menu" id="hero">Hi</p>
    CSS:
    p { color: white; }
    .menu { color: red; }
    (a) blue (b) red (c) white (d) green
  22. 22.⚖️ What colour is the text of this element?
    <h1 class="red" id="hero">Hi</h1>
    CSS:
    h1 { color: purple; }
    h1 { color: blue; }
    (a) blue (b) red (c) green (d) purple
  23. 23.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    #hero { color: blue; }
    #hero { color: orange; }
    (a) white (b) blue (c) orange (d) red
  24. 24.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    #intro { color: purple; }
    #intro { color: green; }
    (a) purple (b) white (c) yellow (d) green
  25. 25.⚖️ What colour is the text of this element?
    <h2 class="red" id="hero">Hi</h2>
    CSS:
    #hero { color: orange; }
    h2 { color: white; }
    .red { color: purple; }
    (a) yellow (b) orange (c) white (d) purple
  26. 26.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    #logo { color: black; }
    #logo { color: red; }
    (a) red (b) blue (c) white (d) black
  27. 27.⚖️ What colour is the text of this element?
    <h1 class="note" id="hero">Hi</h1>
    CSS:
    h1 { color: purple; }
    .note { color: green; }
    #hero { color: orange; }
    (a) purple (b) green (c) orange (d) yellow
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    h2 { color: yellow; }
    .menu { color: white; }
    (a) blue (b) black (c) yellow (d) white
  29. 29.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: white; }
    #top { color: orange; }
    p { color: black; }
    (a) white (b) black (c) purple (d) orange
  30. 30.⚖️ What colour is the text of this element?
    <h2 class="note" id="intro">Hi</h2>
    CSS:
    #intro { color: yellow; }
    #intro { color: blue; }
    (a) red (b) blue (c) yellow (d) orange
  31. 31.⚖️ What colour is the text of this element?
    <h1 class="box" id="hero">Hi</h1>
    CSS:
    #hero { color: blue; }
    #hero { color: black; }
    (a) orange (b) blue (c) black (d) red
  32. 32.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: green; }
    (a) green (b) yellow (c) orange (d) purple
  33. 33.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    .red { color: green; }
    p { color: purple; }
    (a) red (b) purple (c) green (d) yellow
  34. 34.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    .note { color: white; }
    #logo { color: green; }
    p { color: purple; }
    (a) white (b) purple (c) green (d) red
  35. 35.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    .big { color: blue; }
    p { color: green; }
    #end { color: orange; }
    (a) white (b) green (c) orange (d) blue
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="star" id="intro">Hi</h2>
    CSS:
    .star { color: red; }
    .star { color: orange; }
    (a) blue (b) red (c) yellow (d) orange
  37. 37.⚖️ What colour is the text of this element?
    <h2 class="star" id="hero">Hi</h2>
    CSS:
    h2 { color: yellow; }
    .star { color: purple; }
    (a) black (b) blue (c) purple (d) yellow
  38. 38.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    #end { color: green; }
    p { color: blue; }
    (a) purple (b) blue (c) black (d) green
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    h2 { color: purple; }
    .note { color: black; }
    (a) purple (b) orange (c) yellow (d) black
  40. 40.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    #main { color: orange; }
    .box { color: black; }
    (a) red (b) yellow (c) black (d) orange

Answer key

  1. an id selector
  2. green
  3. white
  4. red
  5. purple
  6. white
  7. red
  8. black
  9. red
  10. the later one
  11. blue
  12. green
  13. red
  14. yellow
  15. green
  16. black
  17. white
  18. an element selector
  19. white
  20. white
  21. red
  22. blue
  23. orange
  24. green
  25. orange
  26. red
  27. orange
  28. white
  29. orange
  30. blue
  31. black
  32. green
  33. green
  34. green
  35. orange
  36. orange
  37. purple
  38. green
  39. black
  40. orange

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids