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