← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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