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