← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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