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