← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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