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