← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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