← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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