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

Answer key

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

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