← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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