← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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