← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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