← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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