r/HTML • u/MaganBall • Oct 05 '26
Discussion We live in the big '26...
...yet why the hell are we still using <IMG> ELEMENTS WRAPPED IN <A> ELEMENTS TO LINK AN IMAGE??
We live in a time where boolean functions exist in css, where flexboxes exist, and where <dialog> exists, yet we are STILL linking images like its 1997 and HTML3.2 just dropped instead of just having an href attribute inside the damn img element. Like whats next? am I gna start wrapping my shi in <center> while creating an entire layout out of <table>?
please tell me i aint the only one ticked off by ts
0
Upvotes
4
u/ze_pequeno Oct 05 '26
I just lost a hundred brain cells reading this
2
u/TinyNiceWolf Oct 05 '26
There are lots of page elements we might want to link. Should <span> have an href attribute too? How about <i>? Maybe we should make a big list of every element we might possibly want to link, and then form a committee to discuss which ones are worthy of getting href!
Or just maybe, we could ignore this non-problem and accept that <a> works fine. Yeah, let's do that instead.
12
u/nog642 Oct 05 '26
Because
ais for links andimgis for images? Images aren't inherently clickable. If you want a clickable image you use both. Seems straightforward.1
u/Disgruntled__Goat Oct 05 '26
What’s wrong with img inside a? If you want to put an image/icon and link it to something that’s the way to do it.
1
u/teh_maxh Oct 05 '26
You are. Why would you put an href directly on an image? Do you also think it should go on a list item in a list of links?
1
u/ajamdonut Oct 05 '26
i couldn't give 2 craps if it does the job, <center> obviously breaks rules and <table> for layouts is old ass tech. If you see that it's legacy code. You must continue to use legacy code or risk breaking everything.
If it's new and you see <center> or <table> for layout you need to speak to your boss about your colleagues.
2
u/clickNOICE Oct 05 '26
Not a massive deal if it does the job, right?
2
u/Top_Bumblebee_7762 Oct 05 '26
IMG is not an interactive element.
2
u/dariusbiggs Oct 05 '26
<blink>has some observations..1
u/TomDuhamel Oct 05 '26
Separation on concerns.
<a>is for links and<img>is for images.1
u/teh_maxh Oct 05 '26
You are. Why would you put an href directly on an image? Do you also think it should go on a list item in a list of links?
1
u/octocode Oct 05 '26
<a href="…"> <img href="…" /> </a>
1
u/TinyNiceWolf Oct 05 '26
One of the problems with your bad idea is that it would create an opportunity of confusion between the two attributes of <img> that include URLs. We'd see newbies writing href="image.png" when then meant src="image.png", or swapping the URLs for src and href.
Consider that the notion "clickable link" does not rest in the "href" part. Other elements use href where it doesn't mean "clickable link". The notion "clickable link" is represented by the <a> tag, which is specifically used for that purpose. Your proposal would muddy the meaning behind the tags and attributes, saying that "clickable link" could be indicated either by the <a> tag or by (sometimes) the href attribute. That's just bad design.
1
u/ocelot-373MD Oct 05 '26
0 upvotes and 42 comments is insane