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