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