← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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