header.php代码部分:
<div id="header">
<h1><a href="<?php echo get_option('home'); ?>/" title="风的翅膀"><?php bloginfo('name'); ?></a></h1>
</div>
CSS部分:
#header {
float:left;
width:755px;
text-align:left;
margin:0;
padding:0;
}
#header H1 {
float:left;
text-align:left;
margin:0;
padding:0 0 0 220px;
}
#header H1 A {
display:block;
background:url('images/logoo.gif') no-repeat 0 0;
float:left;
overflow:hidden;
width:155px;
text-indent:-9999px;
height:50px;
}
这样,既可以使用图片标题,又不是简单地使用一个图片链接(这是很通常的写法,就是在需要插入图片的地方用<img>标签插入图片,然后用<a>标签加上链接。这个方法对搜索引擎十分不友好,这样搜索引擎抓取的是张图,而不是文字)。而使之看起来更像是文字标题,因为这里面有H1标签,要知道,搜索引擎可是比较喜欢H1的。
上面的结构中,H1的代码和网站标题的文字对搜索引擎依然可读,而我只是利用text-indent:-9999px;将网站标题远远地扔到可视的界面外面去了了。
演示可见我的博客:
http://www.skyine.cn/