← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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