← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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