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