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