← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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