← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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