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