← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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