← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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