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