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