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

Answer key

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

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