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