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

Answer key

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

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