← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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