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