← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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