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