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