← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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