← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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