← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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