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