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

Answer key

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

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