← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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