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