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