← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 118 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.🌈 Which colour is rgb(255, 0, 0)? (a) magenta (b) black (c) bright green (d) red
  2. 2.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 26px;
      }
    }
  3. 3.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 150px;
      padding: 25px;
      border: 2px solid black;
      margin: 10px;
    }
  4. 4.🔍 Which is the odd one out? (a) changes the text size (b) makes a form box (c) rounds box corners (d) lays out the page
  5. 5.🌈 Which colour is #0000ff? (a) black (b) blue (c) white (d) yellow
  6. 6.🌈 Which colour is #000000? (a) red (b) bright green (c) blue (d) black
  7. 7.🧩 Which language checks a quiz answer? (a) CSS (b) JavaScript (c) HTML
  8. 8.🖌️ Which CSS property centres a heading? (a) font-family (b) text-align (c) font-weight (d) font-size
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    h2 { color: yellow; }
    #intro { color: red; }
    (a) black (b) white (c) red (d) yellow
  10. 10.📱 min-width: 800px applies when the screen is ___. (a) exactly 100px (b) 800px or wider (c) turned off (d) 800px or narrower
  11. 11.🖌️ What colour are the letters?
    h2 {
      color: red;
      background-color: black;
      font-size: 36px;
      text-align: right;
    }
    (a) green (b) red (c) black
  12. 12.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 120px;
      padding: 5px;
      border: 1px solid black;
      margin: 20px;
    }
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="menu" id="hero">Hi</h2>
    CSS:
    #hero { color: blue; }
    #hero { color: white; }
    (a) black (b) purple (c) white (d) blue
  14. 14.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  15. 15.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 640px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  16. 16.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      margin: 10px;
      color: red;
      border: 2px solid;
    }
  17. 17.🖌️ What colour are the letters?
    h2 {
      text-align: center;
      color: red;
      background-color: purple;
      font-size: 24px;
    }
    (a) red (b) white (c) purple
  18. 18.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  19. 19.💪 Which justify-content value puts boxes in the middle? (a) flex-start (b) space-between (c) flex-end (d) center
  20. 20.✍️ Which property is set to 300px in this rule?
    p {
      font-style: italic;
      width: 300px;
      text-align: center;
      border: 2px solid;
    }
    (a) width (b) font-style (c) color (d) 300px
  21. 21.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 16px;
      }
    }
    (a) No (b) Yes
  22. 22.🖌️ Which CSS property sets the letter colour? (a) color (b) font-weight (c) text-align (d) background-color
  23. 23.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    #top { color: black; }
    p { color: yellow; }
    .red { color: red; }
    (a) black (b) red (c) yellow (d) orange
  24. 24.🌈 Which colour is rgb(255, 0, 255)? (a) black (b) bright green (c) yellow (d) magenta
  25. 25.✍️ Which sign goes between a property and its value? (a) = (b) ; (c) - (d) :
  26. 26.💪 Which justify-content value packs boxes at the start? (a) flex-end (b) flex-start (c) space-between (d) center
  27. 27.🖌️ What colour are the letters?
    h2 {
      background-color: orange;
      color: purple;
      font-size: 24px;
      text-align: left;
    }
    (a) white (b) orange (c) purple
  28. 28.✍️ Which property is set to center in this rule?
    body {
      text-align: center;
      font-style: italic;
    }
    (a) background-color (b) margin (c) center (d) text-align
  29. 29.📱 What does a media query check? (a) the time of day (b) the battery level (c) the screen width (d) the page title
  30. 30.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 180px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-size: 20px;
      background-color: yellow;
    }
  32. 32.True or false: padding is space inside the border. (a) True (b) False
  33. 33.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) G (c) J (d) F
  34. 34.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
  35. 35.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 110px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  36. 36.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  37. 37.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 30px;
      }
    }
  38. 38.🎯 What kind of selector is li? (a) a class selector (b) an id selector (c) an element selector
  39. 39.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the br tag (c) the viewport meta tag (d) the hr tag
  40. 40.🎨 Which tag holds CSS inside the head? (a) <script> (b) <body> (c) <style> (d) <css>

Answer key

  1. red
  2. 20
  3. 204
  4. makes a form box
  5. blue
  6. black
  7. JavaScript
  8. text-align
  9. red
  10. 800px or wider
  11. red
  12. 172
  13. white
  14. 20
  15. 80
  16. 3
  17. red
  18. No
  19. center
  20. width
  21. No
  22. color
  23. black
  24. magenta
  25. :
  26. flex-start
  27. purple
  28. text-align
  29. the screen width
  30. 80
  31. 2
  32. True
  33. F
  34. padding
  35. 30
  36. an id selector
  37. 24
  38. an element selector
  39. the viewport meta tag
  40. <style>

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