← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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