← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 209 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ What value is given to font-size in this rule?
    .note {
      font-weight: bold;
      font-size: 20px;
      background-color: yellow;
    }
    (a) center (b) 20px (c) font-size (d) yellow
  2. 2.✍️ CSS declarations go inside which brackets? (a) < > (b) { } (c) ( ) (d) [ ]
  3. 3.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      border: 2px solid;
      margin: 10px;
    }
  4. 4.✍️ Which sign goes between a property and its value? (a) - (b) : (c) = (d) ;
  5. 5.✍️ Which property is set to bold in this rule?
    body {
      font-weight: bold;
      background-color: yellow;
      width: 300px;
    }
    (a) width (b) bold (c) border (d) font-weight
  6. 6.✍️ What is the selector in this CSS rule?
    body {
      border: 2px solid;
      background-color: yellow;
      font-size: 20px;
    }
    (a) border (b) body (c) .box (d) yellow
  7. 7.✍️ Which property is set to 10px in this rule?
    .note {
      margin: 10px;
      width: 300px;
    }
    (a) 10px (b) margin (c) padding (d) font-weight
  8. 8.✍️ What value is given to color in this rule?
    #top {
      color: red;
      font-style: italic;
      font-size: 20px;
    }
    (a) center (b) color (c) 20px (d) red
  9. 9.✍️ What is the selector in this CSS rule?
    body {
      font-size: 20px;
      margin: 10px;
      padding: 8px;
      width: 300px;
    }
    (a) body (b) .box (c) font-size (d) 10px
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      margin: 10px;
    }
  11. 11.✍️ What is the selector in this CSS rule?
    h2 {
      padding: 8px;
      width: 300px;
      border: 2px solid;
    }
    (a) 300px (b) padding (c) h1 (d) h2
  12. 12.✍️ What is the selector in this CSS rule?
    h1 {
      background-color: yellow;
      padding: 8px;
      font-size: 20px;
      border: 2px solid;
    }
    (a) p (b) 8px (c) background-color (d) h1
  13. 13.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) ; (d) .
  14. 14.✍️ What value is given to text-align in this rule?
    body {
      text-align: center;
      width: 300px;
    }
    (a) text-align (b) center (c) yellow (d) 10px
  15. 15.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      margin: 10px;
      font-size: 20px;
      border: 2px solid;
    }
  16. 16.✍️ What value is given to background-color in this rule?
    h1 {
      text-align: center;
      background-color: yellow;
    }
    (a) 10px (b) background-color (c) 8px (d) yellow
  17. 17.✍️ What is the selector in this CSS rule?
    h2 {
      font-size: 20px;
      font-style: italic;
      background-color: yellow;
    }
    (a) font-size (b) h1 (c) italic (d) h2
  18. 18.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      font-weight: bold;
    }
  19. 19.✍️ What is the selector in this CSS rule?
    body {
      border: 2px solid;
      padding: 8px;
      font-size: 20px;
    }
    (a) 8px (b) body (c) border (d) .box
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      border: 2px solid;
    }
  21. 21.✍️ Which property is set to bold in this rule?
    .note {
      font-weight: bold;
      font-size: 20px;
    }
    (a) bold (b) width (c) font-weight (d) border
  22. 22.✍️ Which property is set to 300px in this rule?
    h2 {
      margin: 10px;
      width: 300px;
      border: 2px solid;
    }
    (a) font-style (b) 300px (c) color (d) width
  23. 23.✍️ What is the selector in this CSS rule?
    #top {
      border: 2px solid;
      font-weight: bold;
    }
    (a) border (b) li (c) #top (d) bold
  24. 24.✍️ What is the selector in this CSS rule?
    #top {
      font-size: 20px;
      width: 300px;
    }
    (a) #top (b) 300px (c) li (d) font-size
  25. 25.✍️ What value is given to margin in this rule?
    h1 {
      margin: 10px;
      text-align: center;
    }
    (a) 10px (b) 8px (c) bold (d) margin
  26. 26.✍️ What value is given to width in this rule?
    li {
      text-align: center;
      font-style: italic;
      font-size: 20px;
      width: 300px;
    }
    (a) red (b) italic (c) 300px (d) width
  27. 27.✍️ Which property is set to 20px in this rule?
    .box {
      font-size: 20px;
      background-color: yellow;
      text-align: center;
      font-weight: bold;
    }
    (a) background-color (b) 20px (c) text-align (d) font-size
  28. 28.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
  29. 29.✍️ What is the selector in this CSS rule?
    #top {
      color: red;
      padding: 8px;
    }
    (a) li (b) 8px (c) #top (d) color
  30. 30.✍️ What value is given to background-color in this rule?
    body {
      background-color: yellow;
      margin: 10px;
      text-align: center;
      padding: 8px;
    }
    (a) 8px (b) background-color (c) 10px (d) yellow
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-size: 20px;
    }
  32. 32.✍️ What is the selector in this CSS rule?
    .box {
      font-style: italic;
      padding: 8px;
      text-align: center;
      margin: 10px;
    }
    (a) 8px (b) font-style (c) .box (d) h2
  33. 33.✍️ Which property is set to 8px in this rule?
    p {
      margin: 10px;
      font-size: 20px;
      text-align: center;
      padding: 8px;
    }
    (a) border (b) font-weight (c) 8px (d) padding
  34. 34.✍️ How does a CSS comment start? (a) // (b) # (c) <!-- (d) /*
  35. 35.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
  36. 36.✍️ What is the selector in this CSS rule?
    .note {
      font-style: italic;
      margin: 10px;
    }
    (a) #top (b) font-style (c) 10px (d) .note
  37. 37.✍️ What value is given to font-weight in this rule?
    body {
      width: 300px;
      font-weight: bold;
    }
    (a) 300px (b) 2px solid (c) font-weight (d) bold
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-style: italic;
      margin: 10px;
    }
  39. 39.✍️ What is the selector in this CSS rule?
    body {
      width: 300px;
      margin: 10px;
      font-style: italic;
      text-align: center;
    }
    (a) width (b) .box (c) 10px (d) body
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-size: 20px;
      text-align: center;
      color: red;
    }

Answer key

  1. 20px
  2. { }
  3. 2
  4. :
  5. font-weight
  6. body
  7. margin
  8. red
  9. body
  10. 1
  11. h2
  12. h1
  13. ;
  14. center
  15. 3
  16. yellow
  17. h2
  18. 1
  19. body
  20. 1
  21. font-weight
  22. width
  23. #top
  24. #top
  25. 10px
  26. 300px
  27. font-size
  28. color
  29. #top
  30. yellow
  31. 1
  32. .box
  33. padding
  34. /*
  35. blue
  36. .note
  37. bold
  38. 2
  39. body
  40. 3

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