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