← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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