← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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