← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 159 · 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 kind of selector is .menu? (a) an id selector (b) a class selector (c) an element selector
  2. 2.📦 In the box model, which part is the line round the box? (a) margin (b) padding (c) content (d) border
  3. 3.🎯 What kind of selector is .card? (a) an element selector (b) an id selector (c) a class selector
  4. 4.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      padding: 8px;
    }
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: black; }
    h2 { color: red; }
    #top { color: orange; }
    (a) red (b) orange (c) black (d) purple
  6. 6.✍️ What value is given to margin in this rule?
    h2 {
      margin: 10px;
      padding: 8px;
      border: 2px solid;
      color: red;
    }
    (a) 10px (b) 8px (c) margin (d) bold
  7. 7.📱 What does a media query check? (a) the page title (b) the time of day (c) the screen width (d) the battery level
  8. 8.True or false: HTML changes the text size. (a) False (b) True
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-style: italic;
      border: 2px solid;
      background-color: yellow;
    }
  10. 10.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 70px;
      padding: 15px;
      border: 5px solid black;
      margin: 5px;
    }
  11. 11.🧩 Which language gives the page structure? (a) JavaScript (b) HTML (c) CSS
  12. 12.🌈 Which hex code is yellow? (a) #ff00ff (b) #ff0000 (c) #0000ff (d) #ffff00
  13. 13.🖌️ Where does the text sit on its line?
    h1 {
      font-size: 20px;
      text-align: center;
      background-color: black;
      color: red;
    }
    (a) on the left (b) in the middle (c) on the right
  14. 14.📦 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: 30px;
      border: 2px solid black;
      margin: 5px;
    }
  15. 15.True or false: JavaScript shows a pop-up message. (a) False (b) True
  16. 16.🌈 Which colour is #ff0000? (a) blue (b) white (c) bright green (d) red
  17. 17.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  18. 18.✍️ What is the selector in this CSS rule?
    h1 {
      font-size: 20px;
      background-color: yellow;
    }
    (a) p (b) font-size (c) yellow (d) h1
  19. 19.🎯 Which sign starts a class selector? (a) . (b) & (c) @ (d) #
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      margin: 10px;
      font-weight: bold;
      color: red;
      padding: 8px;
    }
  21. 21.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    #logo { color: purple; }
    #logo { color: white; }
    (a) orange (b) purple (c) black (d) white
  22. 22.🖌️ Which CSS property makes letters bigger? (a) color (b) background-color (c) font-size (d) text-align
  23. 23.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 400px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  24. 24.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 18px;
      }
    }
  25. 25.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
  26. 26.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    h2 { color: orange; }
    #hero { color: purple; }
    .note { color: green; }
    (a) blue (b) purple (c) green (d) orange
  27. 27.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) any number (d) 5
  28. 28.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  29. 29.🌈 In #2a0000 the red part is the hex number 2a. What is it as a normal number?
  30. 30.✍️ Which property is set to 20px in this rule?
    .box {
      font-style: italic;
      font-size: 20px;
    }
    (a) text-align (b) background-color (c) font-size (d) 20px
  31. 31.🌈 In #rrggbb, which colour do the last two digits give? (a) blue (b) white (c) red (d) green
  32. 32.🔍 Which is the odd one out? (a) changes the text size (b) sets colours and fonts (c) counts down a timer (d) lays out the page
  33. 33.✍️ What is the selector in this CSS rule?
    .note {
      font-weight: bold;
      padding: 8px;
      background-color: yellow;
    }
    (a) font-weight (b) 8px (c) .note (d) #top
  34. 34.🖌️ What colour are the letters?
    p {
      color: white;
      font-size: 12px;
      text-align: right;
      background-color: purple;
    }
    (a) orange (b) purple (c) white
  35. 35.💪 Which flexbox property picks row or column? (a) gap (b) display: flex (c) justify-content (d) flex-direction
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: orange; }
    (a) red (b) white (c) green (d) orange
  37. 37.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    .red { color: white; }
    .red { color: black; }
    (a) yellow (b) purple (c) white (d) black
  38. 38.📦 In the box model, which part is a solid or dotted edge? (a) border (b) padding (c) margin (d) content
  39. 39.🌈 Which colour of light is strongest in rgb(158, 58, 35)? (a) blue (b) red (c) green
  40. 40.✍️ Which property is set to bold in this rule?
    p {
      font-weight: bold;
      font-size: 20px;
    }
    (a) bold (b) width (c) font-weight (d) border

Answer key

  1. a class selector
  2. border
  3. a class selector
  4. 1
  5. orange
  6. 10px
  7. the screen width
  8. False
  9. 3
  10. 110
  11. HTML
  12. #ffff00
  13. in the middle
  14. 334
  15. True
  16. red
  17. No
  18. h1
  19. .
  20. 4
  21. white
  22. font-size
  23. 50
  24. 16
  25. 10
  26. purple
  27. 1
  28. an element selector
  29. 42
  30. font-size
  31. blue
  32. counts down a timer
  33. .note
  34. white
  35. flex-direction
  36. orange
  37. black
  38. border
  39. red
  40. font-weight

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