← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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