← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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