← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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