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