← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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