← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 261 · 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.True or false: .menu is an element selector. (a) True (b) False
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: green; }
    (a) red (b) yellow (c) black (d) green
  3. 3.✍️ What value is given to font-weight in this rule?
    p {
      font-weight: bold;
      width: 300px;
    }
    (a) font-weight (b) 300px (c) bold (d) 2px solid
  4. 4.🎯 Which element does the selector #top style? (a) <div class="top"> (b) <div id="intro"> (c) <span class="big"> (d) <div id="top">
  5. 5.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 120px;
      padding: 10px;
      border: 3px solid black;
      margin: 5px;
    }
  6. 6.Which of these is the border? (a) the text or picture (b) the gap round content (c) the line round the box (d) space inside the border
  7. 7.🎯 How many elements on a page should have the same id? (a) 5 (b) 2 (c) 1 (d) any number
  8. 8.🌈 Which colour of light is strongest in rgb(211, 108, 138)? (a) green (b) red (c) blue
  9. 9.True or false: HTML sets colours and fonts. (a) False (b) True
  10. 10.🎯 Which CSS selector matches this element?
    <h1 class="star" id="end">Hello</h1>
    (a) h2 (b) #hero (c) .star (d) .menu
  11. 11.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
  12. 12.🎨 Which tag holds CSS inside the head? (a) <body> (b) <style> (c) <script> (d) <css>
  13. 13.🎯 Which CSS selector matches this element?
    <span class="star" id="main">Hello</span>
    (a) .menu (b) p (c) #logo (d) #main
  14. 14.What does text-align do? (a) makes the text bold (b) makes letters bigger (c) sets the letter colour (d) centres a heading
  15. 15.🔍 Which is the odd one out? (a) makes a link (b) changes the page live (c) makes headings and lists (d) makes a form box
  16. 16.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-size: 20px;
      padding: 8px;
      background-color: yellow;
    }
  17. 17.True or false: margin is space inside the border. (a) True (b) False
  18. 18.⚖️ What colour is the text of this element?
    <h2 class="box" id="logo">Hi</h2>
    CSS:
    h2 { color: purple; }
    .box { color: green; }
    #logo { color: black; }
    (a) green (b) red (c) black (d) purple
  19. 19.🎯 What kind of selector is #hero? (a) an id selector (b) an element selector (c) a class selector
  20. 20.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      font-style: italic;
    }
  22. 22.📱 The screen is 700px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 14px;
      }
    }
    (a) Yes (b) No
  23. 23.✍️ How does a CSS comment start? (a) /* (b) // (c) # (d) <!--
  24. 24.🎨 One CSS file can style how many pages? (a) no pages (b) only one image (c) only one word (d) many pages
  25. 25.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
  26. 26.🔍 Which is the odd one out? (a) sets colours and fonts (b) lays out the page (c) adds space around boxes (d) shows a pop-up message
  27. 27.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) gap (c) display: flex (d) justify-content
  28. 28.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  29. 29.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 150px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  30. 30.⚖️ What colour is the text of this element?
    <h1 class="red" id="end">Hi</h1>
    CSS:
    #end { color: green; }
    h1 { color: orange; }
    (a) green (b) orange (c) black (d) red
  31. 31.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 120px;
      padding: 15px;
      border: 5px solid black;
      margin: 5px;
    }
  32. 32.📱 What does a media query check? (a) the battery level (b) the screen width (c) the page title (d) the time of day
  33. 33.⚖️ What colour is the text of this element?
    <p class="box" id="hero">Hi</p>
    CSS:
    #hero { color: red; }
    .box { color: blue; }
    (a) orange (b) green (c) red (d) blue
  34. 34.🖌️ What colour is behind the letters?
    p {
      font-size: 16px;
      text-align: center;
      background-color: black;
      color: green;
    }
    (a) black (b) green (c) orange
  35. 35.🎯 Which element does the selector #hero style? (a) <h1 id="hero"> (b) <h1 class="hero"> (c) <h1 id="top"> (d) <h2 class="red">
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      padding: 8px;
    }
  37. 37.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
  38. 38.💪 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 40px wide (no margins).
  39. 39.🌈 Which colour of light is strongest in rgb(6, 252, 20)? (a) blue (b) red (c) green
  40. 40.🔍 Which is the odd one out? (a) makes a form box (b) sets colours and fonts (c) lays out the page (d) rounds box corners

Answer key

  1. False
  2. green
  3. bold
  4. <div id="top">
  5. 156
  6. the line round the box
  7. 1
  8. red
  9. False
  10. .star
  11. an id selector
  12. <style>
  13. #main
  14. centres a heading
  15. changes the page live
  16. 3
  17. False
  18. black
  19. an id selector
  20. fits every screen
  21. 1
  22. No
  23. /*
  24. many pages
  25. the later one
  26. shows a pop-up message
  27. justify-content
  28. Yes
  29. 50
  30. green
  31. 170
  32. the screen width
  33. red
  34. black
  35. <h1 id="hero">
  36. 1
  37. 24
  38. 40
  39. green
  40. makes a form box

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