← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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