Skip to main content

2 posts tagged with "inline-block"

View All Tags

My Div Says 'Test' But Takes Up the Whole Width? Understanding Block Elements and Content Size

· 10 min read
Mahmut Salman
Software Developer

I added a child div with just "Test" in it. It's centered perfectly, but when I inspect it in DevTools, the content area is HUGE! 🤔 The div stretches across the entire width even though the text is tiny. I get why it happens (block elements take full width), but shouldn't the div just be the size of "Test"? This conversation taught me the fundamental difference between block-level and inline-level elements—and exactly how to fix it.

Wait, My Buttons Are Still Side-by-Side Without Flex? Understanding inline-block vs Flexbox

· 13 min read
Mahmut Salman
Software Developer

I removed flex from my button container, expecting them to stack vertically, but they're still sitting side-by-side! 🤨 I thought flex was what made them horizontal. My frontend mentor corrected my misunderstanding: buttons are inline-block by default, which means they naturally sit beside each other. This conversation taught me the crucial difference between "happens to be side-by-side" and "controlled side-by-side layout."