问题原文
原帖链接 · usernameabc · CC BY-SA 4.0
We have a request to have an entire block of content be clickable as opposed to just a link field.
Questions:
- Is it good practice to allow for entire block of content to be clickable?
- If we wrap content with link, does that ding our SEO page rankings?
Example:
Link only clickable
<div> <img src="https://placeimg.com/640/480/arch"> <p>Appropriately initiate front-end "outside the box" thinking via flexible intellectual capital.</p> <a href="https://placeimg.com/640/480/nature">My Link</a> </div>Entire block element clickable
<a href="https://placeimg.com/640/480/nature" title="My Link"> <div> <img src="https://placeimg.com/640/480/arch"> <p>Appropriately initiate front-end "outside the box" thinking via flexible intellectual capital.</p> </div> </a>
已采纳解答
原帖链接 · Maximillian Laumeister · CC BY-SA 4.0
Yes, it is fine and even advisable to put block elements inside an a element where appropriate, as long as the browser supports HTML5 (all modern browsers do):
The a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links).
Search engines and browsers will both understand the links just fine.
Further reading:
Is putting a div inside an anchor ever correct? - Stack Overflow
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
