← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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