← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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