← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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