← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 143 · 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(0, 0, 255)? (a) blue (b) white (c) yellow (d) red
  2. 2.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 30px;
      }
    }
  3. 3.✍️ Which property is set to 8px in this rule?
    body {
      padding: 8px;
      text-align: center;
    }
    (a) padding (b) font-weight (c) 8px (d) border
  4. 4.🎯 What kind of selector is #top? (a) an id selector (b) an element selector (c) a class selector
  5. 5.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 90px;
      padding: 20px;
      border: 2px solid black;
      margin: 15px;
    }
  6. 6.🌈 Which hex code is white? (a) #ff00ff (b) #ff0000 (c) #000000 (d) #ffffff
  7. 7.🎯 Which element does the selector li style? (a) <li class="big"> (b) <div> (c) <p id="end"> (d) <span class="big">
  8. 8.🎨 Which attribute adds CSS inside one tag? (a) alt (b) href (c) src (d) style
  9. 9.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  10. 10.🌈 Which colour is #ffffff? (a) bright green (b) white (c) red (d) magenta
  11. 11.🌈 Which colour of light is strongest in rgb(87, 152, 117)? (a) green (b) blue (c) red
  12. 12.🎨 One CSS file can style how many pages? (a) only one image (b) only one word (c) no pages (d) many pages
  13. 13.🧩 Which language lays out the page? (a) HTML (b) JavaScript (c) CSS
  14. 14.💪 Which justify-content value equal gaps, none at ends? (a) flex-start (b) center (c) flex-end (d) space-between
  15. 15.💪 Which justify-content value puts boxes in the middle? (a) center (b) space-between (c) flex-start (d) flex-end
  16. 16.True or false: CSS reacts to a button click. (a) False (b) True
  17. 17.🖌️ Which CSS property colours behind the text? (a) font-weight (b) font-family (c) background-color (d) font-size
  18. 18.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      border: 2px solid;
    }
  19. 19.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 28px;
      }
    }
  20. 20.Which of these does JavaScript do? (a) shows a pop-up message (b) sets colours and fonts (c) changes the text size (d) gives the page structure
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      padding: 8px;
      margin: 10px;
    }
  22. 22.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 1000 (c) 255 (d) 100
  23. 23.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: blue; }
    (a) yellow (b) red (c) blue (d) black
  24. 24.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 200px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  25. 25.🎯 What kind of selector is .card? (a) an id selector (b) a class selector (c) an element selector
  26. 26.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  27. 27.✍️ What is the selector in this CSS rule?
    li {
      width: 300px;
      border: 2px solid;
      margin: 10px;
    }
    (a) width (b) body (c) 2px solid (d) li
  28. 28.✍️ Which sign goes between a property and its value? (a) - (b) ; (c) = (d) :
  29. 29.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 8px;
      }
    }
    (a) Yes (b) No
  30. 30.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 290px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  31. 31.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  32. 32.⚖️ What colour is the text of this element?
    <p class="menu" id="top">Hi</p>
    CSS:
    #top { color: black; }
    p { color: white; }
    (a) blue (b) red (c) black (d) white
  33. 33.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 25px;
      border: 2px solid black;
      margin: 20px;
    }
  34. 34.Which of these is margin? (a) the gap round content (b) space outside the border (c) the text or picture (d) the line round the box
  35. 35.✍️ Which property is set to bold in this rule?
    body {
      font-weight: bold;
      color: red;
      font-style: italic;
      text-align: center;
    }
    (a) border (b) bold (c) font-weight (d) width
  36. 36.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
  37. 37.📦 In the box model, which part is the line round the box? (a) padding (b) content (c) margin (d) border
  38. 38.True or false: the content is the text or picture. (a) True (b) False
  39. 39.What does justify-content: flex-end do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
  40. 40.💪 Which flexbox property picks row or column? (a) justify-content (b) flex-direction (c) gap (d) align-items

Answer key

  1. blue
  2. 24
  3. padding
  4. an id selector
  5. 164
  6. #ffffff
  7. <li class="big">
  8. style
  9. 14
  10. white
  11. green
  12. many pages
  13. CSS
  14. space-between
  15. center
  16. False
  17. background-color
  18. 1
  19. 20
  20. shows a pop-up message
  21. 2
  22. 255
  23. blue
  24. 80
  25. a class selector
  26. an element selector
  27. li
  28. :
  29. Yes
  30. 50
  31. 10
  32. black
  33. 284
  34. space outside the border
  35. font-weight
  36. the later one
  37. border
  38. True
  39. packs boxes at the end
  40. flex-direction

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