← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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