← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 354 · 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.✍️ What value is given to background-color in this rule?
    h2 {
      padding: 8px;
      text-align: center;
      background-color: yellow;
      width: 300px;
    }
    (a) background-color (b) 8px (c) yellow (d) 10px
  2. 2.🌈 Which colour is #ffffff? (a) bright green (b) white (c) yellow (d) magenta
  3. 3.🔍 Which is the odd one out? (a) makes headings and lists (b) counts down a timer (c) reacts to a button click (d) changes the page live
  4. 4.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  5. 5.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 15px;
      border: 4px solid black;
      margin: 0px;
    }
  6. 6.🌈 Which colour is #000000? (a) magenta (b) cyan (c) black (d) blue
  7. 7.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
  8. 8.📱 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
  9. 9.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  10. 10.⚖️ 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
  11. 11.🌈 What is the biggest number one colour can have in rgb()? (a) 255 (b) 99 (c) 1000 (d) 100
  12. 12.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) align-items (d) flex-direction
  13. 13.🔍 Which is the odd one out? (a) changes the page live (b) sets colours and fonts (c) changes the text size (d) rounds box corners
  14. 14.✍️ Which property is set to 8px in this rule?
    #top {
      margin: 10px;
      padding: 8px;
      font-weight: bold;
    }
    (a) 8px (b) font-weight (c) border (d) padding
  15. 15.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) Yes (b) No
  16. 16.True or false: the content is a solid or dotted edge. (a) True (b) False
  17. 17.✍️ Which property is set to italic in this rule?
    #top {
      font-style: italic;
      font-weight: bold;
      padding: 8px;
      margin: 10px;
    }
    (a) italic (b) font-style (c) color (d) font-size
  18. 18.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-start (c) space-between (d) flex-end
  19. 19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 20px;
      }
    }
  20. 20.True or false: padding is space inside the border. (a) True (b) False
  21. 21.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
  22. 22.True or false: p is an element selector. (a) True (b) False
  23. 23.🎯 Which CSS selector matches this element?
    <span class="big" id="hero">Hello</span>
    (a) span (b) .red (c) #big (d) #top
  24. 24.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  25. 25.What does font-size do? (a) colours behind the text (b) makes letters bigger (c) picks the font style (d) sets the letter colour
  26. 26.What does justify-content: flex-start do? (a) puts boxes in the middle (b) packs boxes at the start (c) packs boxes at the end (d) equal gaps, none at ends
  27. 27.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: purple; }
    (a) red (b) blue (c) black (d) purple
  28. 28.Which of these does CSS do? (a) makes headings and lists (b) changes the text size (c) shows a pop-up message (d) makes a form box
  29. 29.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) exactly 100px (d) 800px or narrower
  30. 30.True or false: padding is the gap to other boxes. (a) True (b) False
  31. 31.🎯 Which element does the selector h1 style? (a) <li class="red"> (b) <h1 class="red"> (c) <h2> (d) <div id="logo">
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      border: 2px solid;
    }
  33. 33.🌈 Which colour is #ff00ff? (a) red (b) cyan (c) magenta (d) yellow
  34. 34.✍️ Which sign goes between a property and its value? (a) : (b) ; (c) - (d) =
  35. 35.🧩 Which language makes a form box? (a) JavaScript (b) HTML (c) CSS
  36. 36.✍️ What is the selector in this CSS rule?
    p {
      text-align: center;
      background-color: yellow;
    }
    (a) yellow (b) p (c) text-align (d) .note
  37. 37.🧩 Which language makes a link? (a) CSS (b) JavaScript (c) HTML
  38. 38.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
  39. 39.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      text-align: center;
    }
  40. 40.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 270px;
      padding: 20px;
      border: 2px solid black;
      margin: 0px;
    }

Answer key

  1. yellow
  2. white
  3. makes headings and lists
  4. 20
  5. 98
  6. black
  7. JavaScript
  8. the viewport meta tag
  9. an element selector
  10. the later one
  11. 255
  12. align-items
  13. changes the page live
  14. padding
  15. No
  16. False
  17. font-style
  18. flex-start
  19. 24
  20. True
  21. /*
  22. True
  23. span
  24. JavaScript
  25. makes letters bigger
  26. packs boxes at the start
  27. purple
  28. changes the text size
  29. 800px or wider
  30. False
  31. <h1 class="red">
  32. 1
  33. magenta
  34. :
  35. HTML
  36. p
  37. HTML
  38. 26
  39. 1
  40. 314

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