← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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