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

Answer key

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

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