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

Answer key

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

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