← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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