← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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