← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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