Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道在链接图像上实现标题和 alt 的最佳方法是什么。
img-tag 可以同时具有 title 和 alt 属性,a-tag 只能具有 title 属性。链接图像时,实现标题属性的最佳方法是什么?我应该把它放在 img 和 a-tag 上还是只放在两者之一上?
他们有不同的方法。title-attribute 向元素添加描述,alt-attribute 表现为图像的替代文本表示。
<a href="..." title="Click here for more information about VanGogh"> <img src="vangogh.png" alt="Famous painting of VanGogh" /> </a>