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

Answer key

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

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