← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 305 · 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 colour are the letters?
    p {
      background-color: green;
      text-align: right;
      font-size: 28px;
      color: purple;
    }
    (a) green (b) purple (c) yellow
  2. 2.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 18px;
      }
    }
  3. 3.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <css> (d) <link>
  4. 4.✍️ What is the selector in this CSS rule?
    #top {
      border: 2px solid;
      font-weight: bold;
    }
    (a) border (b) bold (c) #top (d) li
  5. 5.🎯 Which CSS selector matches this element?
    <h1 class="star" id="top">Hello</h1>
    (a) .menu (b) #star (c) #intro (d) h1
  6. 6.🎯 What kind of selector is h1? (a) a class selector (b) an element selector (c) an id selector
  7. 7.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 12px;
      }
    }
    (a) No (b) Yes
  8. 8.🌈 Which colour is #ff00ff? (a) magenta (b) red (c) blue (d) black
  9. 9.🌈 In #rrggbb, which colour do the last two digits give? (a) green (b) white (c) red (d) blue
  10. 10.🧩 Which language sets colours and fonts? (a) CSS (b) JavaScript (c) HTML
  11. 11.⚖️ What colour is the text of this element?
    <h2 class="star" id="intro">Hi</h2>
    CSS:
    #intro { color: white; }
    #intro { color: red; }
    (a) red (b) purple (c) blue (d) white
  12. 12.🖌️ What colour are the letters?
    p {
      text-align: center;
      background-color: purple;
      color: green;
      font-size: 24px;
    }
    (a) green (b) purple (c) blue
  13. 13.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    p { color: red; }
    p { color: white; }
    (a) green (b) orange (c) white (d) red
  14. 14.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 210px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  15. 15.🧩 Which language reacts to a button click? (a) CSS (b) JavaScript (c) HTML
  16. 16.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 460px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  17. 17.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    #end { color: blue; }
    p { color: green; }
    .box { color: red; }
    (a) yellow (b) blue (c) green (d) red
  18. 18.✍️ Which sign ends each CSS declaration? (a) , (b) . (c) ; (d) :
  19. 19.✍️ What value is given to width in this rule?
    p {
      width: 300px;
      font-size: 20px;
      border: 2px solid;
    }
    (a) width (b) 300px (c) red (d) italic
  20. 20.🎨 Which attribute adds CSS inside one tag? (a) href (b) src (c) style (d) alt
  21. 21.🌈 Hex digits go 0 to 9, then A to which letter? (a) G (b) Z (c) F (d) J
  22. 22.✍️ Which property is set to yellow in this rule?
    h1 {
      font-size: 20px;
      width: 300px;
      background-color: yellow;
    }
    (a) padding (b) background-color (c) yellow (d) margin
  23. 23.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    #end { color: orange; }
    #end { color: white; }
    (a) red (b) orange (c) yellow (d) white
  24. 24.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 270px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  25. 25.⚖️ 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
  26. 26.🖌️ What colour are the letters?
    p {
      background-color: purple;
      font-size: 40px;
      text-align: center;
      color: blue;
    }
    (a) red (b) blue (c) purple
  27. 27.True or false: #end is an id selector. (a) False (b) True
  28. 28.📱 What does a media query check? (a) the page title (b) the screen width (c) the time of day (d) the battery level
  29. 29.📦 In the box model, which part is the gap to other boxes? (a) margin (b) border (c) padding (d) content
  30. 30.✍️ What is the selector in this CSS rule?
    li {
      text-align: center;
      width: 300px;
      color: red;
      margin: 10px;
    }
    (a) text-align (b) li (c) body (d) 300px
  31. 31.🎯 Which CSS selector matches this element?
    <li class="note" id="top">Hello</li>
    (a) .big (b) .top (c) .note (d) div
  32. 32.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
  33. 33.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) // (d) #
  34. 34.💪 Which flexbox property sets space between boxes? (a) flex-direction (b) justify-content (c) gap (d) align-items
  35. 35.🧩 Which language lays out the page? (a) HTML (b) JavaScript (c) CSS
  36. 36.🌈 In #006300 the green part is the hex number 63. What is it as a normal number?
  37. 37.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 260px;
      padding: 10px;
      border: 4px solid black;
      margin: 10px;
    }
  38. 38.Which of these does JavaScript do? (a) sets colours and fonts (b) gives the page structure (c) checks a quiz answer (d) puts a picture on a page
  39. 39.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  40. 40.🧩 Which language adds space around boxes? (a) HTML (b) JavaScript (c) CSS

Answer key

  1. purple
  2. 12
  3. <link>
  4. #top
  5. h1
  6. an element selector
  7. Yes
  8. magenta
  9. blue
  10. CSS
  11. red
  12. green
  13. white
  14. 10
  15. JavaScript
  16. 20
  17. blue
  18. ;
  19. 300px
  20. style
  21. F
  22. background-color
  23. white
  24. 70
  25. the later one
  26. blue
  27. True
  28. the screen width
  29. margin
  30. li
  31. .note
  32. an id selector
  33. /*
  34. gap
  35. CSS
  36. 99
  37. 308
  38. checks a quiz answer
  39. 20
  40. CSS

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