0

I know similar questions have been asked a million times, but I have a really specific question regarding SEO and CSS display:none. My understanding is that, from an SEO point of view, it's acceptable to hide elements with display:none, as long as you're not trying to be sneaky and there's something that actually shows the element e.g. JavaScript / jQuery. What if my script doesn't specifically show these elements though? What I mean is say I had the following:

<a class="pin" id="cont1"></a>
<a class="pin" id="cont2"></a>

<div class="container" id="container1">
   <p>Some text</p>
</div>
<div class="container" id="container2">
   <p>Some more text</p>
</div>

The container divs are display:none and clicking on the pin anchors shows the relevant div i.e. pin "cont1" shows "container1" and "cont2" shows "container2" etc. However the script that does this doesn't reference a specific div. Instead it substrings the number from the anchor id to know which div to show i.e.

$('.pin').each(function () {
    $(this).click(function () {
        var contId = $(this).attr('id').substr($(this).attr('id').length - 1);
        var container = document.getElementById('container' + contId);
        if ($(container).css('display') == 'none') {
            $(container).fadeIn();
        } else {
            $(container).fadeOut();
        }
    })
});

Basically, the elements to show/hide are worked out in the script and the actual div id's are not referenced directly. Do you think this approach would be penalized by Google? Would this get picked up as hidden content which is never shown? (even though it actually is)

Anton
  • 432
  • 4
  • 13

1 Answers1

2

No. Google has changed a lot since the days when hiding content with CSS/JS could dupe them. As long as the content you are serving, visible or no, is not spammy, or useless links, or nonsense, you are perfectly fine hiding things as and when you need to. Afterall, if the content is on the page Google can read it so the only disservice you can do yourself is pointless content.

Alex
  • 7,320
  • 1
  • 18
  • 31
  • Thanks! That sounds like a confident answer. I've been googling the topic and just seem to find conflicting info and mixed opinions on the subject. – Anton Mar 10 '14 at 23:55
  • If you're going to downvote, please say why. This is something I work with every day (and read about, being a geek) and content is important if it's right. – Alex Mar 11 '14 at 00:00
  • I tried to accept the answer but on fiddly little phone and caught the down arrow by accident - sorry. I appreciate your help! One thing though - in the link where you said this post is a duplicate, it talks about hiding the content on page load instead of having it hidden to start with. Is this something I should do? – Anton Mar 11 '14 at 00:07
  • For those not having JS it's always worth thinking about progressive enhancment, so from that perspective it would be better to use JS to hide the content. From an SEO perspective, if the content is important (and it should always be!) then it should be physically on the page and hidden with JS on page load, if possible. Will let you off if you remove the downvote ;-) – Alex Mar 11 '14 at 00:10