MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Web Development
CSS
Beginner
Q
What happens to the vertical margins of two adjacent block elements with margin-bottom: 20px and margin-top: 30px?
AThey add up to 50px
BThey collapse to 30px (the larger one)
CThey become 25px
DThey become 20px
Correct Answer:
B. They collapse to 30px (the larger one)
Explanation:
Margin collapsing applies only to vertical margins, and not in flex or grid containers.
ALSO KNOW (related points):
• What does grid-template-columns: 1fr 2fr do? → It creates two columns, with the second taking twice the free space of the first
• Two rules with identical specificity set different colors on the same element. Which one applies? → The rule that appears later in the cascade (source order)
• What is the difference between a CSS transition and a CSS animation? → A transition animates between two states when a property changes; an animation runs keyframes that can loop without any trigger