Suppose we want to make an element (title, image in a container, a block in the sidebar, etc.) reference. This can be implemented by at least the following methods:

  • Wrap the above elements in <a> . This is probably not technically quite correct, because <a> not recommended to be used as a container.
  • Wrap <a> only the contents of the container, not the container itself. I think this is more correct, but I am waiting for your arguments.
  • In general, do not add any links to HTML, but add the necessary redirects by clicking through jQuery . Elegant or not, a moot point; Again, I expect you to say based on your experience.

Which of the above method is optimal?

PS Just please, do not reproach the phrase "more optimal" - "optimal" only one.

    1 answer 1

    The surest method will be the first. In <a> , unlike the rest of the lower-case elements, you can place block elements - this is normal practice in HTML5 . Cards of goods, thumbnails of photos with a brief description, headings (for creating anchors) - all this can be painlessly wrapped by the element <a> .

    You can use the second method, but this will not affect either the semantics or the UX (if only for the worse), but you will have to allocate more CSS for this.

    The third method should be used a little less than never. For this, no one will thank you: neither search engines nor users with disabilities.

    • Thank you for your reply, everything is well argued! - Side Gleb