← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 775 · 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.🖌️ Where does the text sit on its line?
    h1 {
      text-align: left;
      color: blue;
      background-color: orange;
      font-size: 36px;
    }
    (a) in the middle (b) on the left (c) on the right
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      font-size: 20px;
      border: 2px solid;
      font-style: italic;
    }
  3. 3.True or false: #end is an id selector. (a) False (b) True
  4. 4.Which of these does HTML do? (a) changes the page live (b) checks a quiz answer (c) lays out the page (d) makes headings and lists
  5. 5.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    .big { color: yellow; }
    .big { color: orange; }
    (a) orange (b) red (c) yellow (d) black
  6. 6.⚖️ What colour is the text of this element?
    <h2 class="note" id="intro">Hi</h2>
    CSS:
    h2 { color: black; }
    #intro { color: yellow; }
    (a) blue (b) yellow (c) black (d) green
  7. 7.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 90px;
      padding: 30px;
      border: 5px solid black;
      margin: 15px;
    }
  8. 8.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 420px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 100px wide (no margins).
  9. 9.✍️ What value is given to margin in this rule?
    h1 {
      margin: 10px;
      font-style: italic;
      color: red;
      background-color: yellow;
    }
    (a) 10px (b) bold (c) 8px (d) margin
  10. 10.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
  11. 11.📱 What does a media query check? (a) the time of day (b) the page title (c) the screen width (d) the battery level
  12. 12.🌈 Which colour is #00ff00? (a) red (b) cyan (c) black (d) bright green
  13. 13.🎯 Which element does the selector #end style? (a) <span id="end"> (b) <p class="star"> (c) <span class="end"> (d) <span id="hero">
  14. 14.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    p { color: green; }
    p { color: purple; }
    (a) blue (b) purple (c) green (d) white
  15. 15.🎯 How many elements on a page should have the same id? (a) 5 (b) any number (c) 2 (d) 1
  16. 16.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    p { color: white; }
    .box { color: red; }
    (a) red (b) white (c) orange (d) purple
  17. 17.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 120px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  18. 18.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: center;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  19. 19.🌈 Which hex code is blue? (a) #000000 (b) #0000ff (c) #ff00ff (d) #ffff00
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="note" id="main">Hi</h2>
    CSS:
    .note { color: black; }
    #main { color: white; }
    h2 { color: orange; }
    (a) white (b) black (c) orange (d) yellow
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      padding: 8px;
      border: 2px solid;
      font-weight: bold;
      font-style: italic;
    }
  22. 22.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 190px;
      padding: 20px;
      border: 1px solid black;
      margin: 20px;
    }
  23. 23.🎯 Which CSS selector matches this element?
    <span class="star" id="hero">Hello</span>
    (a) #hero (b) #top (c) #star (d) p
  24. 24.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 16px;
      }
    }
  25. 25.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) turned off (c) 600px or narrower (d) exactly 1000px
  26. 26.🌈 In #rrggbb, which colour do the first two digits give? (a) red (b) green (c) black (d) blue
  27. 27.📦 In the box model, which part is the gap to other boxes? (a) border (b) content (c) padding (d) margin
  28. 28.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 16px;
      }
    }
  29. 29.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) - (d) :
  30. 30.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      border: 2px solid;
      margin: 10px;
      padding: 8px;
    }
  31. 31.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  32. 32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 110px;
      padding: 25px;
      border: 5px solid black;
      margin: 5px;
    }
  33. 33.🎯 What kind of selector is #top? (a) an element selector (b) an id selector (c) a class selector
  34. 34.🔍 Which is the odd one out? (a) makes a link (b) makes headings and lists (c) puts a picture on a page (d) shows a pop-up message
  35. 35.🎯 Which CSS selector matches this element?
    <h2 class="box" id="top">Hello</h2>
    (a) li (b) .star (c) #intro (d) h2
  36. 36.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) text-align (d) font-family
  37. 37.What does font-weight do? (a) makes the text bold (b) picks the font style (c) sets the letter colour (d) makes letters bigger
  38. 38.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: purple; }
    (a) purple (b) blue (c) green (d) black
  39. 39.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) # (d) //
  40. 40.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }

Answer key

  1. on the left
  2. 3
  3. True
  4. makes headings and lists
  5. orange
  6. yellow
  7. 190
  8. 60
  9. 10px
  10. HTML
  11. the screen width
  12. bright green
  13. <span id="end">
  14. purple
  15. 1
  16. red
  17. 20
  18. 30
  19. #0000ff
  20. white
  21. 4
  22. 272
  23. #hero
  24. 20
  25. 600px or narrower
  26. red
  27. margin
  28. 20
  29. :
  30. 3
  31. No
  32. 170
  33. an id selector
  34. shows a pop-up message
  35. h2
  36. font-weight
  37. makes the text bold
  38. purple
  39. /*
  40. 24

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