← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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