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

Answer key

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

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