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