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

Answer key

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

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