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

Answer key

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

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