← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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