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