← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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