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

Answer key

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

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