CSS (Properties, Functions, Elements, & Tables) 2 — Questions and Answers
Question 1: Which CSS property controls the space between the content and the border of an element?
- margin
- padding (Correct answer)
- border-spacing
- gap
Correct answer: padding
padding adds space inside an element, between its content and border.
Question 2: What does the CSS calc() function allow you to do?
- Round numbers up
- Perform mathematical calculations to determine a value (Correct answer)
- Animate elements
- Select random colors
Correct answer: Perform mathematical calculations to determine a value
calc() lets you perform calculations like calc(100% - 50px) to set property values.
Question 3: Which property is used to separate the borders of adjacent table cells when border-collapse is set to separate?
- cell-spacing
- border-spacing (Correct answer)
- padding
- table-gap
Correct answer: border-spacing
border-spacing sets the distance between adjacent cell borders in separated-border tables.
Question 4: What is the default value of the position property?
- relative
- absolute
- static (Correct answer)
- fixed
Correct answer: static
static is the default position, placing elements in normal document flow.
Question 5: Which HTML element defines a row in a table?
- <td>
- <tr> (Correct answer)
- <th>
- <row>
Correct answer: <tr>
<tr> (table row) contains the cells that make up a horizontal row.
Question 6: What does the CSS property 'opacity: 0.5' do to an element?
- Hides it completely
- Makes it 50% transparent (Correct answer)
- Doubles its size
- Removes it from flow
Correct answer: Makes it 50% transparent
opacity: 0.5 makes the element 50% transparent while keeping it in the layout.
Question 7: Which property aligns text content to the center horizontally?
- vertical-align: center
- text-align: center (Correct answer)
- align-items: center
- justify-content: center
Correct answer: text-align: center
text-align: center horizontally centers inline content within its container.
Which CSS property controls the space between the content and the border of an element?