1

This is one of those "found in someone else's code and wondering what they're thinking" questions...

The HTML being generated is of the form

<form method="post" action="#">
  <a href="?some&query&string&stuff">
    <img src="https://www.example.com/pictures/pict.gif" /></a>
</form>

The form has no other contents than the anchor and the image inside of it. Is there some reason to wrap an anchor in a form like that?

The only reason I can guess is to make it selectable in CSS, but it would seem the obvious solution for that is a <div class="my_anchor_wrapper">.

So I'm wondering if there's something magic about this construct that I'm missing.

Thanks for any HTMLightenment here.

6
  • Probably just bad coding :o)
    – Steve
    Commented Jan 17, 2019 at 22:06
  • 1
    I wonder if there is some JavaScript elsewhere on the page that finds this element and makes some magic happen. Commented Jan 17, 2019 at 22:22
  • This looks like a Duplicate to this Quesion, the answers there may be helpful.
    – elbrant
    Commented Jan 18, 2019 at 2:26
  • The coder doesn't want Google indexes his queried URLs and hides query in the form.
    – Evgeniy
    Commented Jan 18, 2019 at 10:13
  • @Evgeniy, are you saying that putting a link inside a form element makes Google treat it like it had rel="nofollow" set? I've never heard of that but if it is the case it might make sense here.
    – Tom Swiss
    Commented Jan 18, 2019 at 15:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.