← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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