← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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