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