对于内容很多的页面,我最近开始喜欢使用css :target来只显示所需的内容。代码可能如下所示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test Page</title>
<style type="text/css">
body {font-family:sans-serif;}
#some-content>*,
#some-content>*:target ~ h2:last-of-type,
#some-content>*:target ~ h2:last-of-type+* { display: none; }
#some-content>h2:target,
#some-content>h2:target+*,
#some-content>h2:last-of-type,
#some-content>h2:last-of-type+* { display: block; }
</style>
</head>
<body>
<h1>Test Page</h1>
<ol>
<li><a href="#test-1">First link</a></li>
<li><a href="#test-2">Second link</a></li>
<li><a href="#test-3">Third link</a></li>
<li><a href="#test-4">Fourth link</a></li>
<li><a href="#test-5">Fifth link</a></li>
</ol>
<div id="some-content">
<h2 id="test-1">First header</h2>
<p>First content</p>
<h2 id="test-2">Second header</h2>
<p>Second content</p>
<h2 id="test-3">Third header</h2>
<p>Third content</p>
<h2 id="test-4">Fourth header</h2>
<p>Fourth content</p>
<h2 id="test-5">Fifth header</h2>
<p>Fifth content</p>
</div>
</body>
</html>
我的问题有两个:
发布于 2011-08-04 15:46:12
作为一般规则,蜘蛛不解析CSS。他们通常所做的CSS解析与寻找通过display:none
和其他技巧隐藏起来的可能性有关。,但是仅仅使用这些CSS规则本身并不会给网站带来麻烦,因为这些规则有很多合法的用途。只有当他们被用于斗篷或其他黑色帽子SEO时,才会招致惩罚。
因此,如果您可以在HTML中找到内容,而它不是由CSS或JavaScript创建的,那么蜘蛛将找到并索引该内容。如果它是由JavaScript或CSS动态创建的,那么蜘蛛将找不到它。( Google的可爬行Ajax确实与Google一起工作,但这是构建站点的一种非常糟糕的方式)。
https://stackoverflow.com/questions/6944400
复制相似问题