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