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