← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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