As far as I know, the algo doesn't use anything inside a comment tag to score a page.
I'm no expert, but I would see no reason for anything between comment tags to be considered for a spam penalty.
Comments are (or should be) ignored by browser and robots alike.
But that's just my uneducated opinion.
I have seen over time that engines do read the comment tags I place in CAPITAL letters ... so now the idea comes to write: <!-- <h1> THE KEYWORD </h1> -->
--- what do you think of this?
Haven't seen anyone do it with success for about 5 years - I don't think spamming comment tags would do anything to help rankings these days - but it would probably generate spam reports from competitors if they discovered it.
Zero upside - lots of downside. I would avoid it.
If you were a search engine, what would you do?
The thing to consider as to whether something "can" penalise your site is - 'is there a valid use for this techinique?' Most black hat SEO techniques are in grey areas because there are also legitimate uses for some stuff such as cloaking. But this:
|<!-- <h1> THE KEYWORD </h1> --> |
There is no possible legitimate use for, it can only be spamming.
|There is no possible legitimate use for, it can only be spamming. |
I often comment out parts of my pages when I change things, in case I want to change it back.
It would not be too surprising to find something like this on a page:
<!-- <h1> VAGUE WIDGETS </h1> -->
<!-- <h1> BETTER WIDGETS </h1> -->
<h1> BEST WIDGETS </h1>
Right - that is pretty common. Just one of many reasons why today's search engines don't use commented out sections for indexing. In the early "text match" days of search engines, it often worked.
you typically put H1 tags in your comments?
Only if I'm commenting out mark-up that may need to be put back.
Over the years, I've seen this subject come up periodically. I've checked by searching for unique text strings that appear within the comment tags, and I've never seen an engine return one of these strings.
I have, though, seen Matt Cutts, when reviewing a spammy site, refer to a keyword-laden comment tag he finds as an obvious attempt at spam. Usually, these examples are so far over the top that they're funny.
My assumption is the content inside comment tags will not help you, but, if it's spammy enough, it might hurt you in a manual review.
As for Hx elements and even sections of a page, I also frequently comment them out when I'm making changes. Eventually, I like to go back and clean these up, but that's got nothing to do with search engines.
In regard to SEO, comment tags also add to page weight. Keeping your file size down by only using comments to demarcate code blocks concisely would be best. IE. Marking the begining and end of a header, footer etc. If thats even necessary.
I could be splitting hairs, but using comment tags to deactivate deprecated or unused code may possibly reduce the potential SERP relevancy. Irrelevant source code prevents important content from being as topmost as possible, and will contribute to file size/load time.
All things to consider when in it to win it with SEO.
HTML Comments are treated as markup...
3 On SGML and HTML - 3.2.4 Comments
I like it when people try to get fancy with their comments. You know, stuff like this...
<!-- My HTML Comment -- Let's add some separators -- This should help with the visual -->
Do you see what's wrong with the above? ;)
We use HTML Comments all the time. Along with CSS Comments, ASP Comments, JS Comments, etc. Without them, our development teams would have questions.
The double hyphens between comment open tags and close tags cause an invalidation. But, is there a specific reason other than just don't do it?
Your right pageoneresults, about the developers needing references in the source code to prevent confusion.
Thanks for the W3C reference too.