← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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