← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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