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