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