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