← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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