← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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