← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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