← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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