← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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