带有背景图像且无文本的 XHTML 锚链接
是否有可能有锚链接,里面没有文字,有背景图像和固定尺寸,并且仍然有利于搜索引擎优化?
CSS 示例:
a{display:block;width:50px;height:20px;background-image:url('images/background.jpg');background-repeat:no-repeat;background-position:0 0;}
a:hover img{background-position:0 -20px;}
Is it possible to have anchor links no text inside that has a background image and fixed dimensions and still be good for SEO?
Example CSS:
a{display:block;width:50px;height:20px;background-image:url('images/background.jpg');background-repeat:no-repeat;background-position:0 0;}
a:hover img{background-position:0 -20px;}
Example HTML:<a href="#"></a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果图像中包含文本,或者您只是想添加其描述,您可以做的一件事是帮助 SEO 和可访问性,即为锚点提供带有大负文本缩进的标题和内容,例如将其添加到您的
a
CSS:...使用以下 HTML:
If the image has text in it or you simply want to add its description, one thing you can do to help SEO and accessibility is to give the anchor a title and content with a large negative text-indent, like adding this to your
a
CSS:...with the following HTML:
受到 neXib 对另一个答案的评论的启发。
HTML:
CSS:
只要 div 具有“溢出:隐藏”和固定尺寸,内部图像就可以定位在其中,以仅显示您想要的精灵部分。
SEO 也是我关心的一个问题,我认为这个解决方案会很好用。
Inspired by neXib's comment on another answer.
HTML:
CSS:
So long as the div has 'overflow: hidden' and fixed dimensions the image inside can be positioned within to only display the part of the sprite you want.
SEO was a concern for me too and I think this solution will work fine.
搜索引擎看不懂,那对SEO有什么好处呢?更重要的是,你为什么要这样做,你想做什么?
The search engine can't read it, so how would it be good for SEO? More importantly, why do you want to do this, what are you trying to do?
使用alt和title属性,但是标签内没有内容是没有意义的。我认为你在搜索结果中存在受到惩罚的严重风险!
再说一次,你为什么要尝试这个。您正在制作链接到另一个页面的按钮吗?
运行 JavaScript 函数?
Use alt and title attribute, but having no content inside the tags is pointless.I think that there is a serious risk that you will be penalized in the search results!
Again, why are you trying this. Are you doing buttons that are linking to another page or that
run a javascript function?
这不就能解决问题吗?
嗯,这是一个有点老的问题,但只是想对此发表意见!
Wouldnt this fix the problem?
Well this is a bit old question but just want opinion on this!