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