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