← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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