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