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