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