← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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