← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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