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