← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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