← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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