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

Answer key

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

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