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