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

Answer key

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

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