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

Answer key

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

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