← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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