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