← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 408 · 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 does a media query check? (a) the battery level (b) the page title (c) the time of day (d) the screen width
  2. 2.✍️ What value is given to background-color in this rule?
    body {
      border: 2px solid;
      background-color: yellow;
      font-weight: bold;
      width: 300px;
    }
    (a) 10px (b) 8px (c) background-color (d) yellow
  3. 3.✍️ What value is given to margin in this rule?
    .note {
      margin: 10px;
      width: 300px;
      font-size: 20px;
      font-style: italic;
    }
    (a) 8px (b) bold (c) 10px (d) margin
  4. 4.🌈 In #8a0000 the red part is the hex number 8a. What is it as a normal number?
  5. 5.⚖️ What colour is the text of this element?
    <h1 class="big" id="intro">Hi</h1>
    CSS:
    #intro { color: red; }
    #intro { color: purple; }
    (a) black (b) red (c) purple (d) yellow
  6. 6.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    p { color: green; }
    #main { color: red; }
    .menu { color: yellow; }
    (a) green (b) red (c) yellow (d) orange
  7. 7.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
  8. 8.🌈 Which colour is rgb(0, 255, 0)? (a) blue (b) bright green (c) black (d) white
  9. 9.🌈 Which colour is rgb(0, 0, 255)? (a) cyan (b) red (c) blue (d) yellow
  10. 10.True or false: .menu is an id selector. (a) True (b) False
  11. 11.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  12. 12.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    h2 { color: white; }
    h2 { color: blue; }
    (a) blue (b) white (c) yellow (d) green
  13. 13.📦 In the box model, which part is the line round the box? (a) content (b) margin (c) border (d) padding
  14. 14.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 80px;
      padding: 30px;
      border: 3px solid black;
      margin: 5px;
    }
  15. 15.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 180px;
      padding: 15px;
      border: 4px solid black;
      margin: 5px;
    }
  16. 16.🌈 In #00006a the blue part is the hex number 6a. What is it as a normal number?
  17. 17.🖌️ Where does the text sit on its line?
    li {
      text-align: right;
      background-color: white;
      color: purple;
      font-size: 32px;
    }
    (a) on the left (b) in the middle (c) on the right
  18. 18.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 8px;
      }
    }
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  20. 20.📦 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: 10px;
      border: 2px solid black;
      margin: 15px;
    }
  21. 21.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 180px;
      padding: 30px;
      border: 1px solid black;
      margin: 10px;
    }
  22. 22.Which of these does HTML do? (a) sets colours and fonts (b) adds space around boxes (c) shows a pop-up message (d) makes a link
  23. 23.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      color: red;
      font-size: 20px;
    }
  24. 24.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) [ ] (d) ( )
  25. 25.🧩 Which language changes the text size? (a) JavaScript (b) CSS (c) HTML
  26. 26.🌈 Which colour is #ffffff? (a) black (b) red (c) cyan (d) white
  27. 27.🌈 Which colour is rgb(0, 0, 0)? (a) blue (b) cyan (c) yellow (d) black
  28. 28.🔍 Which is the odd one out? (a) makes a form box (b) gives the page structure (c) puts a picture on a page (d) rounds box corners
  29. 29.💪 Which flexbox property spaces boxes along a row? (a) justify-content (b) align-items (c) gap (d) flex-direction
  30. 30.🖌️ Where does the text sit on its line?
    h2 {
      text-align: center;
      background-color: red;
      color: blue;
      font-size: 12px;
    }
    (a) on the right (b) in the middle (c) on the left
  31. 31.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
  32. 32.⚖️ What colour is the text of this element?
    <h1 class="red" id="hero">Hi</h1>
    CSS:
    .red { color: white; }
    #hero { color: orange; }
    h1 { color: yellow; }
    (a) orange (b) yellow (c) white (d) black
  33. 33.⚖️ What colour is the text of this element?
    <h1 class="red" id="intro">Hi</h1>
    CSS:
    #intro { color: orange; }
    #intro { color: yellow; }
    (a) orange (b) red (c) yellow (d) purple
  34. 34.🎯 Can many elements share the same class? (a) No (b) Yes
  35. 35.✍️ In color: blue; which part is the value? (a) : (b) blue (c) ; (d) color
  36. 36.🌈 In #000032 the blue part is the hex number 32. What is it as a normal number?
  37. 37.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      color: red;
    }
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-style: italic;
    }
  39. 39.🌈 Which colour is #ffff00? (a) bright green (b) yellow (c) blue (d) red
  40. 40.🖌️ What colour are the letters?
    li {
      background-color: black;
      font-size: 24px;
      color: blue;
      text-align: right;
    }
    (a) blue (b) orange (c) black

Answer key

  1. the screen width
  2. yellow
  3. 10px
  4. 138
  5. purple
  6. red
  7. an element selector
  8. bright green
  9. blue
  10. False
  11. an id selector
  12. blue
  13. border
  14. 156
  15. 228
  16. 106
  17. on the right
  18. 8
  19. 10
  20. 94
  21. 262
  22. makes a link
  23. 3
  24. { }
  25. CSS
  26. white
  27. black
  28. rounds box corners
  29. justify-content
  30. in the middle
  31. CSS
  32. orange
  33. yellow
  34. Yes
  35. blue
  36. 50
  37. 1
  38. 1
  39. yellow
  40. blue

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