1

Today, I ran across a tag, in the site of some acquaintances, that seems to have a structural flaw. But, I thought I would check whether my impression is on track before I mention it to them.

In what situations/purposes would using h2 as a class inside an h1 tag be a useful structure: <h1 class="heading h2"> ?

2
  • 1
    You mean <h1 class=h2>? Dec 7, 2023 at 2:16
  • Thanks for the reminder. I had copied the code and forgot to paste it. I will add it to my question. Dec 8, 2023 at 4:21

1 Answer 1

3

Class names don't really mean anything as it relates to the structure of the page.

I suspect that your friend needed an h1 heading but liked the styling of the h2 class better.

You see this a lot with pre-developed frameworks (e.g. Bootstrap) where the base styling might not fit with what the developer is trying to go for. So rather than creating a new class or adding inline styles, they just opt for whatever is there (and maybe even leverage additional inline styles).

From a structure stand point, the tag is still communicating to search engines, accessibility tools, etc that it is an h1.

1
  • That makes a lot of sense. That tag is on a site that uses a common shopping cart service. I have found it awkward enough to do custom coding on in that service, that I can see the temptation to cut corners. Dec 8, 2023 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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