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