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

Answer key

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

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