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

Answer key

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

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