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

Answer key

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

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