← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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