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