← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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