← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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