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