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