← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 941 · 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.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
  2. 2.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 70px;
      padding: 20px;
      border: 5px solid black;
      margin: 0px;
    }
  3. 3.True or false: p is an id selector. (a) False (b) True
  4. 4.🧩 Which language gives the page structure? (a) CSS (b) JavaScript (c) HTML
  5. 5.True or false: the border is a solid or dotted edge. (a) True (b) False
  6. 6.✍️ How does a CSS comment start? (a) /* (b) # (c) // (d) <!--
  7. 7.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  8. 8.🌈 Hex digits go 0 to 9, then A to which letter? (a) J (b) F (c) G (d) Z
  9. 9.⚖️ What colour is the text of this element?
    <h1 class="red" id="logo">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: purple; }
    (a) blue (b) purple (c) orange (d) yellow
  10. 10.🌈 Which hex code is black? (a) #ffff00 (b) #000000 (c) #ff0000 (d) #ff00ff
  11. 11.🖌️ What colour are the letters?
    h1 {
      background-color: red;
      color: blue;
      text-align: left;
      font-size: 32px;
    }
    (a) blue (b) red (c) green
  12. 12.🎯 Which CSS selector matches this element?
    <h1 class="box" id="logo">Hello</h1>
    (a) #box (b) .star (c) .logo (d) h1
  13. 13.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <link> (d) <css>
  14. 14.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  15. 15.🌈 Which colour is rgb(255, 0, 255)? (a) blue (b) red (c) white (d) magenta
  16. 16.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) , (d) ;
  17. 17.What does justify-content: flex-start do? (a) puts boxes in the middle (b) equal gaps, none at ends (c) packs boxes at the end (d) packs boxes at the start
  18. 18.What does font-family do? (a) colours behind the text (b) picks the font style (c) sets the letter colour (d) makes letters bigger
  19. 19.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 26px;
      }
    }
  20. 20.💪 Which flexbox property sets space between boxes? (a) display: flex (b) flex-direction (c) justify-content (d) gap
  21. 21.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 2 (b) 6 (c) 4 (d) 3
  22. 22.🎯 Which CSS selector matches this element?
    <h1 class="note" id="top">Hello</h1>
    (a) .note (b) .big (c) #intro (d) #note
  23. 23.🖌️ What colour are the letters?
    p {
      text-align: right;
      font-size: 36px;
      color: black;
      background-color: blue;
    }
    (a) orange (b) blue (c) black
  24. 24.🧩 Which language sets colours and fonts? (a) JavaScript (b) HTML (c) CSS
  25. 25.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector
  26. 26.🔍 Which is the odd one out? (a) puts a picture on a page (b) reacts to a button click (c) counts down a timer (d) changes the page live
  27. 27.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      color: red;
      width: 300px;
    }
  28. 28.⚖️ Which selector is the strongest? (a) an element selector (b) a class selector (c) an id selector
  29. 29.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  30. 30.What does justify-content: flex-end do? (a) equal gaps, none at ends (b) packs boxes at the end (c) puts boxes in the middle (d) packs boxes at the start
  31. 31.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 190px;
      padding: 5px;
      border: 3px solid black;
      margin: 20px;
    }
  32. 32.True or false: li is an element selector. (a) False (b) True
  33. 33.What does color do? (a) picks the font style (b) makes letters bigger (c) sets the letter colour (d) centres a heading
  34. 34.💪 Which justify-content value equal gaps, none at ends? (a) center (b) space-between (c) flex-end (d) flex-start
  35. 35.⚖️ Two rules with the same selector set a colour. Which one wins? (a) neither (b) the later one (c) the first one (d) the shorter one
  36. 36.True or false: JavaScript gives the page structure. (a) True (b) False
  37. 37.🖌️ Where does the text sit on its line?
    p {
      color: orange;
      text-align: center;
      font-size: 12px;
      background-color: black;
    }
    (a) on the right (b) in the middle (c) on the left
  38. 38.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 6px;
      }
    }
    (a) Yes (b) No
  39. 39.🎯 Can many elements share the same class? (a) Yes (b) No
  40. 40.🌈 In #000042 the blue part is the hex number 42. What is it as a normal number?

Answer key

  1. 28
  2. 120
  3. False
  4. HTML
  5. True
  6. /*
  7. JavaScript
  8. F
  9. purple
  10. #000000
  11. blue
  12. h1
  13. <link>
  14. No
  15. magenta
  16. ;
  17. packs boxes at the start
  18. picks the font style
  19. 20
  20. gap
  21. 3
  22. .note
  23. black
  24. CSS
  25. an element selector
  26. puts a picture on a page
  27. 2
  28. an id selector
  29. Yes
  30. packs boxes at the end
  31. 206
  32. True
  33. sets the letter colour
  34. space-between
  35. the later one
  36. False
  37. in the middle
  38. No
  39. Yes
  40. 66

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