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