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