← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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