← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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