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

Answer key

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

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