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