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