← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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