← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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