← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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