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