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