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