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