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

Answer key

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

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