Hiding with style (literally)

Hiding links/content with CSS

CSS is a very powerful technology that can be used to hide links. It is rendered on client's browser and it's good at hiding links from search engine robots. There are endless ways to manipulate content when this technology is used creatively.

Here are some most popular ones:

#element_id { display: none; }

In the example above CSS property display is used. This is the simplest way to hide html element, thus it's very easily detectable by search engine robots. A similar technique is using visibility attribute:

#element_id { visibility : hidden; }

Despite the fact that this technique is easily detectable, there are no direct penalties for this. It is completely legitimate to hide some blocks of information and show them only when a user performs certain actions (clicks a button, fills a form, etc.).

Another way to make an element almost invisible is to reduce its size to one pixel. It will appear very small to the user and almost unnoticeable when used near bright images or flash animation. It can be done like this:

#element_id { font-size: 1px; }

This is also easily detectable by robots. Specifying 1 pixel height font obviously looks suspicious.

Matching text color with background:

#element1 { color: #fff; background-color: #fff; }
#element2 { color: #fff; background-image: url('background.jpg'); }

This technique is much better because it is almost undetectable by robots. In the example above element1 has the same text color as background (white). It is pretty easy to spot such CSS rule, but if multiple cascading elements are used and background color is specified on the top element, and font color is specified on an inner element, robots can't tell if the text is visible. Nowadays robots still can't render HTML and CSS properly (to be precise - they can't render almost anything1).

The second element element2 has an image as background. It is also more tricky for search engines to understand what is in the image (the image may contain some colors, but still the part where text appears may be white), and seo web developer can also disallow search engines to read images via robots.txt at all.

However, this trick might be spotted easily by humans. The most common method for a human reviewer is to select the whole page (this can be done by hitting CTRL+A or CMD+A if you are on a Mac). When all the elements on the page are selected they change their color slightly. So, your previously defined CSS rules do not work.

A little more advanced version of this method is to use almost similar but not quite the same text and background colors. It is even harder for search engines to spot this, but still it's not a silver bullet against human beings.

Positioning:

#element_id {
    position: absolute;
    left: 0px; top: -500px;
    width: 1px; height: 1px;
    overflow: hidden;
}

In the example above the element is positioned somewhere off the viewable screen area. Such method is hard to detect for both humans and robots. Robots can't parse CSS effectively and humans won't see any text even when the whole text is selected.

There is a similar but plainer technique called Rundle's Text-Indent Method:

#element_id { text-indent: -9000px; }

Such methods are very popular among web accessibility protagonists, since the hidden text is still read by screen readers. So, wisely used this can be considered safe.

Similar techniques are widely used to replace texts with images. For more information see: "Using Background-Image to Replace Text".

A more tricky solution could be to place links behind some other html element:

#element1 { position: absolute; left: 0; z-index: 1; }
#element2 { position: absolute; left: 0; z-index: 4; }

In this case element2 is placed on top of element1 using CSS z-index property (in CSS elements have 3 dimensions: x,y, and z).

Even more interesting link/content hiding techniques can be used when you take a look at CSS specification using a creative approach. Here are some examples:

#element_id { letter-spacing: 8000px; overflow: hidden; }

In this example extremely huge letter spacing is used. It means that spaces between letters would be too big to fit in the screen. To avoid the first letter of text appearing on screen you can simply start sentence with space. The attribute overflow: hidden simply means that no scroll bar is needed for such a wide text.

#element_id:before {
    content: 'Some replacement';
    margin-right: 8000px;
}

#element_id {
    overflow: hidden;
}

In this case a special CSS 2.1 selector :before is used. In the example above text is shifted to the right and the replacement text shown instead. If you want to learn more about CSS selectors I highly recommend this selector's tutorial by 456 Berea st.

This article is a part of SEO design patterns - hiding links. You could also be interested in other articles from this series:

Footnotes

  1. It's simply not their thing: search engines are meant to read and parse text and later on find it when someone types it in search query. Some basic CSS parsing techniques may be applied to catch spammers, but still not a single one search engine can render CSS like browser does. Real text appearance can only be examined by human reader.