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