← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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