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