← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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