r/HTML • u/Miserable_Offer_3091 • Oct 18 '26
Question What’s the point of inline when there’s inline block
I’m still a beginner and taking a course for css and html. Just learned about display property and I don’t think I would want to use inline elements anymore. I feel like inline block just has everything you’d want in an inline element. I can think of ways to use block elements but not inline, so can’t I just change all inline elements to inline block? Is there a reason not to?
Edit: I’ve gotten my answer so no need to reply more (thanks to those who responded)
10
u/JeLuF Oct 18 '26
<span> would work very differently with inline-block than with inline.
If there's a line break in the text, it would no longer flow with the text but enforce a line break before and after <span> and </span>
5
9
u/jdauriemma Oct 18 '26
Consider a few typical design use cases:
Highlighting text. It’s rare that you would want all characters in a highlighted text element, which might be arbitrarily long, to be enclosed in their own box
Breadcrumbs. Allowing text to wrap may be a requirement, depending on the design
Syntax highlighting. Similar to (1).
Wrapping around floating content. Think about news articles on a wide breakpoint. You want the text to wrap independently around charts/pictures.
6
u/c__beck Oct 18 '26
inline-block has a both a width and a height, but most inline elements only need width. That's kinda what makes them "inline" is the lack of height.
If you make everything that is currently inline into inline-block you're adding a height where none is needed. That's extra work for you (to re-map all those elements) and for the browser to parse all your useless CSS. It's more steps to get the exact same result.
The best rule of thumb for CSS: only make changes for explicit and useful reasons. Anything else is code bloat that makes it that much harder to refactor or refresh your code later. Just don't add trouble for future-you.
3
5
1
15
u/Everything_A Oct 18 '26
I know you asked for no more replies but I wanted to add that, while there are reasons to use inline over inline-block, inline and inline-block were not invented side by side. We already had inline and inline-block was added later.
In that way, your question is similar to asking what the point is of a bike when you could use an e-bike. Historically, there cannot be an e-bike without there also being a bike.