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