← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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