← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 942 · 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 color do? (a) centres a heading (b) picks the font style (c) sets the letter colour (d) makes letters bigger
  2. 2.✍️ What is the selector in this CSS rule?
    .note {
      padding: 8px;
      border: 2px solid;
    }
    (a) #top (b) 2px solid (c) padding (d) .note
  3. 3.✍️ What is the selector in this CSS rule?
    p {
      font-style: italic;
      font-weight: bold;
      font-size: 20px;
      color: red;
    }
    (a) bold (b) .note (c) p (d) font-style
  4. 4.🌈 In #160000 the red part is the hex number 16. What is it as a normal number?
  5. 5.True or false: .card is a class selector. (a) False (b) True
  6. 6.⚖️ What colour is the text of this element?
    <h1 class="note" id="logo">Hi</h1>
    CSS:
    h1 { color: blue; }
    #logo { color: purple; }
    .note { color: black; }
    (a) purple (b) black (c) orange (d) blue
  7. 7.True or false: padding is the gap round content. (a) True (b) False
  8. 8.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      color: red;
    }
  9. 9.🎯 Which element does the selector #hero style? (a) <p id="top"> (b) <h1 class="menu"> (c) <p id="hero"> (d) <p class="hero">
  10. 10.🎯 What kind of selector is #main? (a) a class selector (b) an id selector (c) an element selector
  11. 11.🎯 Which CSS selector matches this element?
    <h2 class="star" id="main">Hello</h2>
    (a) h2 (b) .main (c) #logo (d) #star
  12. 12.🌈 In #380000 the red part is the hex number 38. What is it as a normal number?
  13. 13.💪 Which flexbox property turns on flexbox? (a) gap (b) display: flex (c) justify-content (d) flex-direction
  14. 14.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 8px;
      }
    }
  15. 15.📦 In the box model, which part is the gap round content? (a) padding (b) content (c) margin (d) border
  16. 16.🧩 Which language makes a link? (a) HTML (b) CSS (c) JavaScript
  17. 17.True or false: the border is the line round the box. (a) True (b) False
  18. 18.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 160px;
      padding: 20px;
      border: 2px solid black;
      margin: 20px;
    }
  19. 19.True or false: li is a class selector. (a) False (b) True
  20. 20.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  21. 21.🎯 How many elements on a page should have the same id? (a) 5 (b) 1 (c) any number (d) 2
  22. 22.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 50px;
      padding: 15px;
      border: 5px solid black;
      margin: 0px;
    }
  23. 23.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title
  24. 24.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  25. 25.🧩 Which language changes the page live? (a) JavaScript (b) HTML (c) CSS
  26. 26.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 26px;
      }
    }
    (a) Yes (b) No
  27. 27.🎯 Which element does the selector .box style? (a) <h2 class="star"> (b) <h2 id="box"> (c) <li class="menu"> (d) <h2 class="box">
  28. 28.🎯 Which element does the selector span style? (a) <h2 id="main"> (b) <p> (c) <span class="note"> (d) <h1 class="note">
  29. 29.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 110px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  30. 30.⚖️ What colour is the text of this element?
    <h1 class="star" id="top">Hi</h1>
    CSS:
    h1 { color: white; }
    h1 { color: purple; }
    (a) purple (b) blue (c) white (d) red
  31. 31.📦 In the box model, which part is space inside the border? (a) margin (b) content (c) padding (d) border
  32. 32.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 28px;
      }
    }
    (a) No (b) Yes
  33. 33.🌈 Which colour is rgb(0, 255, 255)? (a) blue (b) white (c) red (d) cyan
  34. 34.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
  35. 35.🎨 A CSS file usually ends with which extension? (a) .css (b) .js (c) .html (d) .png
  36. 36.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) J (c) Z (d) F
  37. 37.🧩 Which language changes the text size? (a) JavaScript (b) CSS (c) HTML
  38. 38.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 8px;
      }
    }
    (a) Yes (b) No
  39. 39.True or false: img is an element selector. (a) True (b) False
  40. 40.💪 Which justify-content value packs boxes at the start? (a) center (b) flex-end (c) space-between (d) flex-start

Answer key

  1. sets the letter colour
  2. .note
  3. p
  4. 22
  5. True
  6. purple
  7. True
  8. 1
  9. <p id="hero">
  10. an id selector
  11. h2
  12. 56
  13. display: flex
  14. 8
  15. padding
  16. HTML
  17. True
  18. 204
  19. False
  20. an id selector
  21. 1
  22. 90
  23. the screen width
  24. Yes
  25. JavaScript
  26. No
  27. <h2 class="box">
  28. <span class="note">
  29. 10
  30. purple
  31. padding
  32. No
  33. cyan
  34. .
  35. .css
  36. F
  37. CSS
  38. No
  39. True
  40. flex-start

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