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