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