← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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