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