← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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