← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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