← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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