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

Answer key

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

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