← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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