← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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