← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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