← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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