← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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