3

My website does not currently use H1 and H2 tags, but I want to use them and hide them to make my site SEO friendly.

  • 6
    Bad idea. Hiding text from users while showing it to Googlebot is called cloaking. Far from being SEO friendly, that will get your website completely kicked out of the search results. – Stephen Ostermiller Apr 28 '17 at 10:03
  • 2
    The advice that you should use H1 and H2 tags is also outdated. Google no longer cares about what tags you use and does not rank keywords in certain tags more. Now Google renders pages and gives more weight to large, prominent text. Using CSS to style any text using any tag to be large and bold at the top of the page will give that text the same boost that H1 and H2 tags used to get. – Stephen Ostermiller Apr 28 '17 at 10:11
  • I don't know what your site looks like but you could always use h1 and h2 tags for their semantic purpose (and for search) but use css to style them to look like the rest of your text. – Mark_1 Apr 28 '17 at 13:07
6

You can't hide h1 and h2 tags (or any text for that matter) and still have them apply positively to SEO.

For several years now, Google has been trying to index precisely what the user sees. Google is able to intelligently process CSS and now JavaScript to achieve this goal. If the user doesn't see it then there is no point it being indexed.

Delivering different content to Google than to users is called cloaking. A black hat SEO technique from yesteryear, will likely see you actively penalised in the SERPs these days.

All search engines don't necessarily work the same way as Google, but since Google is currently by far the most prolific search engine, it is Google that governs how we must behave.

  • This isn't always true and hiding content off screen is often implemented. It depends on where the placement is and its content. I have some old web pages that still rank high despite doing this very thing. Not something to recommend in all cases but Google does not label all hidden content as cloaking. – Rob Apr 28 '17 at 12:33
  • @Rob That really depends if there is an intention to display the content at some point - the result of some user action - that is OK. Or perhaps old-style text-replacement - the hn tag is still visible, but the text itself isn't. However, this doesn't appear to fit the OP's scenario? – MrWhite Apr 28 '17 at 15:59
1

It is easy to hide them when you can add them to your PHP Code. Just add the following CSS properties to your style file.

h1,h2 {
  display: none;
}

Or, if you use jQuery as JavaScript framework you can do the same in JS:

$(document).ready(function() {
  $('h1,h2').css('display', 'none');
});

I would recommend using the CSS only solution.

  • 4
    "...while still having them for SEO" - this would seem to be the main part of the question. If you simply hide them with CSS/JavaScript then Google will either ignore them or actively penalise your site for cloaking - in other words, a bad idea, as Stephen suggests in comments. – MrWhite Apr 28 '17 at 10:20
0

For Google just focus on your content. What you can do is use heading elements which do not actually add any real change to your document but will flag which part is the heading.

For other less popular search engines you can still do the cloaking but I would recommend against it.

0

I'm not sure if this will solve your issue, but would making the text be the same color as the background achieve what you want? Considering the answers above, it might be enough to get the result you're after, but keep the text "hidden" from the user. It's sneaky, but the only thing I can come up with aside from CSS:

visibility: hidden;

You might also consider placing it under a graphic.

Personally, I stay away from stuff like this, because I wouldn't want to risk having my site ranked lower or banned.

Another technique might be to just put an image on the page with the alt="whatever your important info is." It's legit and while not as powerful, might do the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.