← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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