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