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