← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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