← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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