← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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