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