One developer said that it's better to avoid adding a class and another attribute to page headings i.e. to
h1-h6 as it impacts SEO.
Is that true?
Or maybe it includes only
Or does it not matter at all?
Applying a class is fine as long as you don't do silly things like move the h1 somewhere silly, make it smaller than your text or not the prominent title or make it the same colour as the page
Applying a class itself is not harmful. But you can do harm with your CSS
It definitely can. Headings determine what is important on a page from an SEO perspective. They declare to a search engine what a page is about and clue the search engine's spiders in on the content of a page.
A page is structured so that H1 is the topic of the page, h2 is often a breakdown of that topic and h3 is a break down of the h2. Here is a great example so that you can visualize this:
<H1> Red Trucks</h1> <p>text talking about red trucks.</p> <h2> Buy Red Trucks</h2> <p> text talking about buying red trucks.</p> <h3>Buy Used Red Trucks</h3> <p> text talking about buying used red trucks</P> <h3>Buy New Red Trucks</h2> <p> Text talking about buying new red trucks</p> <h2> Sell Red Trucks</h2> <p>text about selling red trucks</p> <h3> Sell a used red truck</h3> <p>Text about selling used red trucks</p> <h3> Sell a new red truck</h3> <p> text about selling a new red truck.</p>
Each step is a break down giving a bit more information on what the section of a page is about.
In this example:
H1 says: This is the general topic, aka red trucks.
H2 says: We buy and sell red trucks.
H3 says: We buy new or used red trucks and we sell new or used red trucks.
The page is now broken up into 4 sections as far as a search engine is determined. Section 1: Buy Used Red Trucks Section 2: Buy New Red Trucks Section 3: Sell Used Red Trucks Section 4: Sell New Red Trucks
This is important as those keywords are associated with those sections so if you put a link or something with one of those sections Google will assume that the page you are linking to has something to do with red trucks. Also if you put an image in the section google will assume it has to do with red trucks.
Now here is where your question comes in: If the H Tags are mislabeled, it will make google start to question your content and your trustworthiness.
It expects the information in an h3 labeled sell new red trucks, to be about selling new red trucks. It has other ways to gather information too. Like if your image has an alt tag saying, "Bob arrested for arson", on the sell used red trucks section of a page titled red trucks, it's going to be a bit confused. You'll be sending mixed signals.
Having Htags that don't match the page will cause you to show up lower for certain terms in your initial rankings.
When a new page is ranked for the first time, Google tries to take the best guess on how useful it will be to its searchers. It'll look at factors like speed, technical seo, how consistent keyword strength is and more to attempt to determine the overall strength of the page. If the Htags are not used properly it will almost certainly have an effect on which keywords the page is ranking for and as a direct result, it will affect initial rankings.
On the flip side Not having htags at all puts you at a disadvantage to those that do have them. If you have them and they are used properly they help you rank higher on the search. If you have them and they are used improperly they will make you rank lower and will dilute your page keyword strength.
In Conclusion If you are going to use H Tags for classes, try to make sure it shows up with the proper structure like the example above or you'll damage your SEO efforts.