HTML : why cant i use link feature inside the table tag ? the <a href="#"> <td>abc</td></a> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

HTML : why cant i use link feature inside the table tag ? the <a href="#"> <td>abc</td></a>

25th Sep 2021, 5:15 AM
Lo0pZz
24 Answers
+ 7
Because <td> as the table cell can contain other tags. But on the other hand, <a> can only contain the hyperlink text, nothing more ...
25th Sep 2021, 5:32 AM
Ipang
+ 3
You should've enclosed the <a> within the <td> <td><a href="#">abc</a><td>
25th Sep 2021, 5:20 AM
Ipang
+ 3
Thank you , it worked. But why do we have to do it like that? Why doesn't it work when <td> is enclosed inside <a>
25th Sep 2021, 5:25 AM
Lo0pZz
+ 3
Its not that <a> tag can't contain other html elements The fact is that <tr> only accept <td> elements as its children Not other html elements like <a> etc. If i am wrong somewhere correct me
26th Sep 2021, 2:31 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
Arnav Kumar That is exactly what I mean. You only read it and translate it as is. My words were a discouragement, for the misuse, or may I say, *abuse* of hyperlink from its original purpose. And it is because I don't want the beginners out there (who happen to see this) to try and do what those "hackers" do, in a thought it was justifiable.
26th Sep 2021, 3:00 PM
Ipang
+ 3
Arnav Kumar Don't say that man please ... You mentioned the black hole thing too remember? I'm not gonna change my original comment. Let those who visit this thread later see the whole thing, and know my true intention why I wrote it that way.
26th Sep 2021, 3:20 PM
Ipang
+ 2
Ohh got ittt . Thank you
25th Sep 2021, 5:33 AM
Lo0pZz
+ 2
No problem 👌
25th Sep 2021, 5:33 AM
Ipang
+ 2
Amav Kumar, Except for an <img> I hardly see anyone put in other HTML in a hyperlink.
26th Sep 2021, 2:30 PM
Ipang
+ 2
Arnav Kumar I know you're great with the web stuffs. But you read my statement only from your view. But then you freely judge that I'm one of those who needs to see to believe. Who are you to judge me man?
26th Sep 2021, 2:44 PM
Ipang
+ 2
Ipang I just replied to your these words "But on the other hand, <a> can only contain the hyperlink text, nothing more ..." You said nothing more but now you are atleast saying it can take in images so isn't it be a bit misleading and confusing to a beginner out there
26th Sep 2021, 2:47 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 2
Arnav Kumar I thank you for your comment. It opens a new point of view for those who reads my comment. If they too misunderstood it, then they get to see my original intention.
26th Sep 2021, 3:11 PM
Ipang
+ 2
Ipang Arnav Kumar friends chill
26th Sep 2021, 3:23 PM
Lo0pZz
+ 1
Ipang btw <a> tag can contain other html elements
26th Sep 2021, 2:27 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 1
Arnav Kumar thanks :)
26th Sep 2021, 2:34 PM
Lo0pZz
+ 1
Ipang if i have never seen a black hole that doesn't mean that it doesn't exist I have seen people wrapping whole <body> content in <a> tag Especially hackers that want to take user to another site wherever they click on the screen I myself tried wrapping other elements in <a> and it works
26th Sep 2021, 2:37 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 1
Arnav Kumar the hacking part makes sense.
26th Sep 2021, 2:39 PM
Lo0pZz
+ 1
Ipang There's so many good cases too Like Google wraps search results in links so that wherever user clicks on that area, the link gets opened but if they only wrap text in link then there maybe accessibility problems Other uses would be wrapping a div that is a profile card will take to that profile
26th Sep 2021, 3:03 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 1
Arnav Kumar I hope your argument still relates to the original problem, where a <td> enclosed in <a> doesn't work. Otherwise the "good cases" list can go on infinitely..
26th Sep 2021, 3:06 PM
Ipang
+ 1
Ipang btw your that comment was already there before i did a comment And that hacker one was just an example nothing more than that And imagine if i hadn't commented then whole time Lo0pZz would had been thinking that he can only use texts inside <a> tag not anything more (until he figures out on his on)
26th Sep 2021, 3:08 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar