← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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