← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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