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