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