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

Answer key

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

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