← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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