← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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