← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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