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

Answer key

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

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