← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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