← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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