I know that h1 tag is important for SEO, so all my title is H1 (bravo!)
Now, I need to have a title (as the first line of a text ) a little different on some pages.
Usually, I just duplicate h1 as h2 and alternate.
The question: Is it possible to add a class to the title tag... (I have try without success)
The < title > tag is in your < head > section, so it wouldn't really make sense to add a class to it.
You can add a class to your < h1 > tag, though.
Sure you can:
The
class
attribute is a in the attribute group coreattrs of core attributes that can be used with theh1
element.It sounds like you are using
h1
for all titles on the page. Typically you would have a singleh1
tag on the page for what the page contains (with text at least partly matching the title of the page), and lesser header tags for headlines of different parts of the content. That way you give most information to the search engines about what's important on the page. There are of course pages that doesn't fit into this model, but many do.There are many different ways that you can specify a style for headers. For example:
For all
h1
tags:For all
h1
andh2
tags:For all
h1
tags inside an element withid="main"
:For all
h2
tags withclass="Info"
:For all
h3
tags inside an element withclass="More"
:The following should work:
You can style a header like this:
Or like this:
If it's not working:
Edit:
It sounds like you had
h1 .myClass
instead ofh1.myClass
- there's an important distinction: