← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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