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

Answer key

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

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