← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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