← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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