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