← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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