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