← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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