← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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