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