CSS CSS Technology Applications 2 — Questions and Answers
Question 1: Which CSS property is used to create space between the element's border and its content?
- margin
- padding (Correct answer)
- border-spacing
- gap
Correct answer: padding
Padding controls the space inside the border, between the border and the content.
Question 2: What does the CSS 'z-index' property control?
- Horizontal stacking
- The stacking order of positioned elements (Correct answer)
- Zoom level
- Element opacity
Correct answer: The stacking order of positioned elements
z-index determines the vertical stacking order of positioned elements along the z-axis.
Question 3: Which value of 'position' removes an element from the normal document flow and positions it relative to its nearest positioned ancestor?
- static
- relative
- absolute (Correct answer)
- sticky
Correct answer: absolute
position: absolute removes the element from flow and positions it relative to the nearest positioned ancestor.
Question 4: In a CSS Flexbox container, which property aligns items along the main axis?
- align-items
- justify-content (Correct answer)
- align-content
- flex-wrap
Correct answer: justify-content
justify-content distributes and aligns flex items along the main axis.
Question 5: What does the universal selector '*' target in CSS?
- The root element only
- All elements on the page (Correct answer)
- Only block elements
- Pseudo-elements only
Correct answer: All elements on the page
The universal selector (*) matches every element in the document.
Question 6: Which unit is relative to the font size of the root element?
- em
- rem (Correct answer)
- px
- pt
Correct answer: rem
The rem unit is relative to the root element's (html) font size.
Question 7: What is the default value of the 'display' property for a <div> element?
- inline
- block (Correct answer)
- inline-block
- flex
Correct answer: block
A <div> is a block-level element by default, so its display value is block.
Which CSS property is used to create space between the element's border and its content?