Day 3: The Display Property & Margin Collapse
Daily Objective
Section titled “Daily Objective”Master the display property to transform element flow behavior and understand margin collapsing.
1. Values of display
Section titled “1. Values of display”block: Takes full width; respectswidth,height, and vertical margins/paddings.inline: Flows with text; ignoreswidth,height, and vertical margins.inline-block: Flows horizontally like inline text, but respectswidth,height, and padding!none: Removes the element completely from document flow.
.nav-link { display: inline-block; padding: 0.5rem 1rem;}2. Margin Collapse
Section titled “2. Margin Collapse”When two vertical margins touch, they collapse into a single margin equal to the largest of the two (they do not add together!).
Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Build a horizontal navigation bar using
display: inline-blockon anchor elements. - Place two paragraphs with
margin-bottom: 30pxandmargin-top: 20pxand inspect the resulting 30px collapsed space in DevTools.