← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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