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

Answer key

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

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