← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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