← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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