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

Answer key

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

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