← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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