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