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

Answer key

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

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