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

Answer key

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

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