← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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