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