← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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