← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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