← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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