← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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