← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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