← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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