← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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