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

Answer key

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

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