← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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