← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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