← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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