← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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