← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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