← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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