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

Answer key

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

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