← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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