← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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