← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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