How not to hide text

We had one fun question at Pubcon where people sort of asked about what are the different ways to hide text and what should I and shouldn't I do? I want to show you a couple slides about how you should not do it.

This is an example of hidden text that we recently came across, and it's almost like a brain teaser.

So I'll show you the first slide. C string equals new resource extra noted. C display equals, and then they piece together a whole bunch of substrings of C string.

And then you can see getelement by ID style display equal C display.

Now what is this even doing? What does this code do when a browser executes it?

I'll let you think about it for just a second. Okay, you ready?

Let's go to the next slide and highlight what are the substrings that are actually pulled out of that top string?

It's N-N-O-E.

And in fact, if you look at the order in which it's pulled out, it's really N-O-N-E none.

So what's really happening here is someone's taking a string and they're pulling out the individual characters that correspond to none.

And then they say, okay, now this none set the style display.

So CSS wise set the display to none.

So it's a very sneaky way of hiding some text using code.

Now we caught this because we can parse some code and we can execute some JavaScript and we can really interpret what the page is doing in a lot of situations.

So my advice is not to use this as a method to hide your code because this looks as suspicious as it can possibly get.

Whenever we see someone doing something like this, we pretty much know they're trying to hide text, and they're trying to do it in such a way that people don't know that they're hiding the text.

So this is definitely not something that I would recommend if possible, try to make the text visible to users visible to Googlebot.

If it's good text, why not show it to everybody?

Don't try to do really sneaky tricks to hide it so that, oh, they won't be able to find it this way because that really sets up in opposition to users.

You're trying to deceive your users, you're trying to deceive search engines, and that's the sort of stuff that can get your site penalized in the long term.