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