开发者

How do search engines treat content shown by :target? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about programming within the scope defined in the help center.

Closed 9 years ago.

Improve this question

For pages with a lot of content I've recently become fond of using css :target to show only the desired content. The code may look something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-e开发者_运维百科quiv="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>

My question is twofold:

  1. Do modern spiders follow anchor links?
  2. If not, would only the last h2 and its following sibling be spidered?


As a general rule spiders do not parse CSS. What CSS parsing they do typically has to do with finding possible cloaking through display:none and other tricks. But just using these CSS rules in-and-of themselves are not going to get a site into trouble as there are lots of legitimate uses for these rules. It's only when they are used for cloaking or other black hat SEO that a penalty will be incurred.

So if you can find the content in your HTML, and it is not created by CSS or JavaScript, then the spiders will find and index that content. If it is dynamically created by JavaScript or CSS then it will not be found by the spiders. (Google's crawlable Ajax does work with Google but that's a very bad way to go about building a site).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜