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