似乎存在一些不同的技术,所以我希望能得到一个关于这个问题的“权威”答案……
在网站上,创建一个链接到首页的徽标是一种常见做法。我想做同样的事情,同时更好地针对搜索引擎、屏幕阅读器、IE 6+ 以及禁用了 CSS 和/或图像的浏览器进行优化。
示例一:不使用 h1 标签。这对 SEO 不太好,对吧?
<div id="logo">
<a href="">
<img src="logo.png" alt="CreandoLaRed" />
</a>
</div>
示例二:我在某处找到了这个。
<h1 id="logo">
<a href="">CreandoLaRed</a>
</h1>
/* css */
#logo {
padding: 70px 0 0 0;
overflow: hidden;
background-image: url("logo.png");
background-repeat: no-repeat;
height: 0px !important;
height //:70px;
}
示例三:相同的 HTML,使用文本缩进的不同方法。这是图像替换的“Phark”方法。
<h1 id="logo">
<a href="">CreandoLaRed</a>
</h1>
/* css */
#logo {
background: transparent url("logo.png") no-repeat scroll 0% 0%;
width: 250px;
height: 70px;
text-indent: -3333px;
border: 0;
margin: 0;
}
#logo a {
display: block;
width: 280px;
height: 120px;
text-decoration: none;
border: 0;
}
示例四:Leahy-Langridge-Jefferies 方法。当图像和/或 css 被禁用时会出现。
<h1 id="logo" class="logo">
<a href="">CreandoLaRed</a>
</h1>
/* css */
h1.logo {
margin-top: 15px;
position: relative;
overflow:hidden;
padding: 0;
}
h1.logo a {
position: absolute;
height: 0;
width: 100%;
background-position: left top;
background-repeat: no-repeat;
}
h1#logo {
height: 60px;
}
h1#logo a {
padding-top: 60px;
background-image: url("logo.png");
}
对于这类事情,哪种方法最好?请在回答中提供 html 和 css。