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

Answer key

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

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