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