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

Answer key

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

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