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

Answer key

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

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