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