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

Answer key

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

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