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