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

Answer key

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

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