There are many frustrations that I have had in my short dev game so far, and one of them crossed my eyes very recently again while I was working on...
For further actions, you may consider blocking this person and/or reporting abuse
Very insightful. Everyone knows the best way to help beginners is to make them feel stupid and unwelcome for sharing what they’ve learned...
It is not wrong to correct mistakes, but all you have done here is berate a beginner for sharing something that they have learned, calling it clickbait, and then question them for not having learned it earlier. This article clearly wasn’t written for you.
You haven’t corrected a mistake.
What exactly is wrong with the title anyway? What would you call this article?
This is a side tangent: If you ever onboard junior devs please take more care when communicating with them.
Thank you for commenting.
To me it wasn't obvious from the beginning and it was also not one of the first things I learned when starting with HTML (by making W3School tutorials). It was not intuitive for me to suggest that IMG elements are inline elements just by looking at websites.
Also, I guess that - despite this being in the HTML spec since version 1 - a lot of developers have experienced similar issues when using images, without knowing what causes them. It is a simple thing, but it wasn't obvious to me and I think it is not obvious to quite a few developers out there.
I think it doesn't matter if it is simple or not or if it is already around for years. If people struggle with it or don't know what it is about, it's something worth writing about. I tried to fill a gap, because I couldn't find a comprehensive article myself and wanted to make a valuable contribution. Dev.to is the perfect community for such - a community that is grateful for learning from others people's learnings, and sharing their own learnings, which is what I did.
So in that sense it was the strange <img> gap that was somehow there for me. And, assuming that other people have the same problem, the title The strange <img> gap in HTML is no clickbait at all, but rather the most helpful title for the ones who have the problem themselves, and who do not simply know that it is so simple because it was in the HTML spec since version 1. Writing an article about it was the choice that reached the most people - and hopefully helped a lot of them.
I hope that clarifies my intentions for the article.
I added an additional paragraph and further reading links to the end of the article.
If you have suggestions for articles and links, please let me know.
I often find myself looking at the element panel in my console and then looking at what rules an element inherits from the agent.
I can only recommend using that whenever you have a little downtime - a lot to learn by just inspecting.
Thank you for sharing your findings, the breakdown you made are actually quite good.
In most cases,
display: inline-block
is what you want (unless you wantfloat
, which inherently formats as block content.For me
inline-block
does not fix this particular issue. Butinline-block
orinline-flex
can be used and they also give more flexibility.Vertical align-related issues can be so frustrating.
global img { display: block; max-width: 100% } is always at the top of my css file
Seriously tho... are you actually trying to be helpful? 🙄
@christiankaindl thanks so much for this article even though it's been a few years since it was published, trust me, it's really helpful, I couldn't find any other documentation that explains it, I also looked for this issue in stackoverflow and nothing really concrete was mentioned, I am a beginner in all this, this literally saved my project, since I couldn't find any official document that has this type of info.
@christiankaindl Thanks so much for this article, I never knew about this. I guess I never thought about what does it really mean to be inline.
I was on rollercoaster first cursing the world, to realizing this makes sense :D
I always use
float: left
to the image to fix this issue. But still not a solid sulution.Yeah,
float: left
is a fast fix but it can also brak a layout very easily. A good alternative can bedisplay: inline-flex
instead of usingfloat
.Had this yesterday. The kind of bizarre issue that is so easy to fix and yet so illusive.