SEO-friendly HTML structure example

Hey there! I got a quick question on structuring my HTML especially on heading-levels. I have a design with eyebrow headings (basically a subtitle but above the title) so the eyebrow will be a h3 and the title a h2. Is it fine to place the h3 eyebrow above the h2 title inside my HTML structure? Or do I bother to do the following, since it brings me more benefits then flaws?
<div class="test">
<h2>This is a title</h2>
<h3>This is an eyebrow subtitle</h3>
</div>
<div class="test">
<h2>This is a title</h2>
<h3>This is an eyebrow subtitle</h3>
</div>
.test {
display: flex;
flex-direction: column-reverse;
}
.test {
display: flex;
flex-direction: column-reverse;
}
57 Replies
vince
vince2mo ago
No One sec let me elaborate lol If you look up headings in MDN, you'll see this: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements#usage_notes
Do not skip heading levels: always start from <h1>, followed by <h2> and so on.
I'd use an hgroup here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hgroup
The <hgroup> element allows the grouping of a heading with any secondary content, such as subheadings, an alternative title, or tagline. Each of these types of content represented as a <p> element within the <hgroup>.
So maybe you can try something like this:
<hgroup>
<p class="eyebrow">This is some overline text</p>
<h1>Hello, world!</h1>
</hgroup>
<hgroup>
<p class="eyebrow">This is some overline text</p>
<h1>Hello, world!</h1>
</hgroup>
Hidi_
Hidi_OP2mo ago
I will have a h1 as visually-hidden, so you would suggest the hgroup with a paragraph and a h2?
vince
vince2mo ago
Regarding the original example too, I see what you're trying to go for but that feels really hacky, in any case I don't think you'll get that much benefit from including an h3 over using something more semantic like hgroup but as always I could be proven wrong My h1 was just an example, feel free to use an h2 if it's below an h1, but I'm not sure you're exact use case. Do you mind sharing what the h1 is & context of what you're trying to achieve?
Hidi_
Hidi_OP2mo ago
This is basically my current structure just looking at headings
<h1 class="visually-hidden">Design Portfolio Name</h1>

<h3>Name</h3>
<h2>Multimedia Designer</h2>

<h4>Design page</h4>
<h3>3D Collection</h3>
<h1 class="visually-hidden">Design Portfolio Name</h1>

<h3>Name</h3>
<h2>Multimedia Designer</h2>

<h4>Design page</h4>
<h3>3D Collection</h3>
b1mind
b1mind2mo ago
Don't use headings visually only semantically Ignore the sizes of them would you still right it like that? probably not xD Agree with Vince don't sleep on <heading> and <hgroup> you can even combine the too to really style up headings with mustaches or beards then just use <b><i><span><p> w/e
Hidi_
Hidi_OP2mo ago
I didn't write the headings like this for font-size or whatever, was looking to make it best for SEO-cases and screen-readers. But I guess there are better ways?
b1mind
b1mind2mo ago
main
heading
<h1>Design Portfolio Name</h1>
<i>Multimedia Designer</i>
section/article
<h2>Design page</h2>
p stuff about design not a link list though
<h2>3D Collection</h2>
p stuff about collection
main
heading
<h1>Design Portfolio Name</h1>
<i>Multimedia Designer</i>
section/article
<h2>Design page</h2>
p stuff about design not a link list though
<h2>3D Collection</h2>
p stuff about collection
Please never use headings inside <a>'s If you really want to make it good for SR you need to download and use a SR to test with to truly understand (imo) But SR's use Heading lists, link lists, landmark region lists to navigate mostly Far as SEO goes you just want to make sure you are using the proper struct and heading levels as Vince said Very rare will you need a H3 for example for that you would have a page title, section title, subsection title<h3> or like in a <aside> You also have "reader modes" that will want a <article> with proper direct heading to enable it in browsers with support
Hidi_
Hidi_OP2mo ago
This is an example of one of the eyebrows (this case "Design page"). Probably doesn't deserve a h2?
No description
b1mind
b1mind2mo ago
no 3d collect would be the only heading there* mustache should just be a div/span/i/em/b/strong/ w/e that would also depend how you wanted it read outloud
vince
vince2mo ago
Honestly, 'design page' as a heading will probably not really help your seo efforts anyway
b1mind
b1mind2mo ago
nope it wouldn't xD
Hidi_
Hidi_OP2mo ago
yeah true, I thought just for screen readers 😂 but I feel like SR is so complex that I won't cover it all anyways
b1mind
b1mind2mo ago
Also whats in the heading is not going to help with SEO as much as you think it might.. Its more about having the proper structure
vince
vince2mo ago
Maybe it'll help google understand your page a bit better but I doubt your rankings would increase all too much but maybe I'm wrong
b1mind
b1mind2mo ago
no you are not wrong vince, again whats in the heading matters little I would match your title and h1 though Should be pretty much identical imo
Hidi_
Hidi_OP2mo ago
so Multimedia Designer as h1?
b1mind
b1mind2mo ago
but like sitename - title | or w/e no the <title> Match w/e you do for the <h1>
Hidi_
Hidi_OP2mo ago
oh yeah makes sense the mustache thing is kinda unclear for me, should I check it out?
b1mind
b1mind2mo ago
🤷‍♂️ I mean think of it this way maybe You will never have a heading be a sibling right after another heading so
<h2>
<h3>
<h2>
<h3>
the H3 would be a sub title inside the section
article
h2
section
h3
article
h2
section
h3
so unless you are going another level down don't use it
article
header
b look ma i grow hair
h1 main heading of page/article
p some tagline
section
h2 first section
p words
section
h2 section section
p words
article
header
b look ma i grow hair
h1 main heading of page/article
p some tagline
section
h2 first section
p words
section
h2 section section
p words
Hidi_
Hidi_OP2mo ago
that makes more sense So something like this?
<h1 class="visually-hidden">Design Portfolio Name</h1>
<main>
<div class="profile-card">
<hgroup>
<p>Name</p>
<h2>Multimedia Designer</h2>
</hgroup>
</div>

<div class="project-card">
<img src="" alt="">
</div>

<div class="project-info">
<hgroup>
<p>Design page</p>
<h2>3D Collection</h2>
</hgroup>
</div>
</main>
<h1 class="visually-hidden">Design Portfolio Name</h1>
<main>
<div class="profile-card">
<hgroup>
<p>Name</p>
<h2>Multimedia Designer</h2>
</hgroup>
</div>

<div class="project-card">
<img src="" alt="">
</div>

<div class="project-info">
<hgroup>
<p>Design page</p>
<h2>3D Collection</h2>
</hgroup>
</div>
</main>
b1mind
b1mind2mo ago
Also I will use <header> before <hgroup> but I'll use <hgroup> in a header 😄
article
header
hgroup
h1 title
p tagline
img()
section
header
h2 sub head
i some note
p main words
article
header
hgroup
h1 title
p tagline
img()
section
header
h2 sub head
i some note
p main words
Some reason I found that <hgroup> was not being seen in Edges readermode but it would inside the <header> rather it would not engage the icon for reader mode* I would use section in this case not hgroups also the h1 should be inside main idk why you are visually hiding it though 🤔 Lots of times if you visually hide something you will want to hide it from a reader too. Or vise versa
Hidi_
Hidi_OP2mo ago
I'm hiding it cus it's not within the design, but I feel like all my other headings are not h1's cus they don't really say what the page is
b1mind
b1mind2mo ago
I don't get what they are 😄 context is lost for me I think but thats ok I still wouldn't hide a H1 🤔
Hidi_
Hidi_OP2mo ago
This is the design for my portfolio
No description
b1mind
b1mind2mo ago
I would make your name the h1 in that
Hidi_
Hidi_OP2mo ago
The visible text that could be a h1 is my title
b1mind
b1mind2mo ago
actually I would make all of name+title the h1
Hidi_
Hidi_OP2mo ago
job-title or whatever u wanna call it 😂
b1mind
b1mind2mo ago
So like
<h1>
<span> Hidee Van Hassel </span>
Multimedia Designer
</h1>
<h1>
<span> Hidee Van Hassel </span>
Multimedia Designer
</h1>
sorry I write in pug 🤣
Hidi_
Hidi_OP2mo ago
haha no worries
b1mind
b1mind2mo ago
That is how I would do that design personally
Hidi_
Hidi_OP2mo ago
and then just style the span to make it break and stuff
b1mind
b1mind2mo ago
Then the 3d collective would be a section with h2
Hidi_
Hidi_OP2mo ago
awesome make all those cards sections?
b1mind
b1mind2mo ago
I would yea inside a <main>
Hidi_
Hidi_OP2mo ago
I just did plain divs rn
b1mind
b1mind2mo ago
You could make them Articles too its debatible which xD
Hidi_
Hidi_OP2mo ago
yeah I was looking at articles, however the smallest card doesnt say much on it's own its connected to the image above
b1mind
b1mind2mo ago
Yea I've seen arguments where article for cards does make sense but I can't brain atm.
Hidi_
Hidi_OP2mo ago
alright awesome, gonna make some changes. Thanks!
b1mind
b1mind2mo ago
dig the design gl!
Hidi_
Hidi_OP2mo ago
I will most likely reach out to people instead of being reached out to, but.... good practice is always good practice 😉 thanks! I've been struggling a lot with getting it to work, but i'll keep trying haha appreciate ur time and explanation
b1mind
b1mind2mo ago
yea np I'm passionate about semantic html/a11y/seo so xD makes it easy. I do recommend installing w/e free SR you can to test with though if you do care. (you might be surprised at how it works/or site is read out)
Hidi_
Hidi_OP2mo ago
do they show areas of improvement? or just show how it works
b1mind
b1mind2mo ago
https://www.sarasoueidan.com/blog/testing-environment-setup/ (older but still great starting off point of reference and why its good to test than just slapping aria on stuff)
Hidi_
Hidi_OP2mo ago
i'll have a read, it's very interesting oh btw i'll have the project title h2 most likely hooked up with js to change the title, that should be fine right? change title on button press to change between projects
b1mind
b1mind2mo ago
Only the first loaded one will matter for SEO*. But it would be fine. I'm not sure if it would change for the SR I would assume so ( yes it seems to) If you wanted all those cards to work with SEO they need to be in the DOM in the first load, then hide/show with JS Or use a CSS only for your carousel vs js at all 😅
Hidi_
Hidi_OP2mo ago
probably just gonna change the innerHTML, thanks
b1mind
b1mind2mo ago
just so you know that still wont be read by SEO, any JS a user has to interact with to inject data won't. Google claims its better about JS fetched data on load* but having all the info in the DOM for the first crawl/parse is still best. Its one reason why SSR/Static are still best for SEO (that and speed)
Hidi_
Hidi_OP2mo ago
so there is a way for css only to change text and image when interacting with an arrow image?
b1mind
b1mind2mo ago
You would just hide/unhide it visually
Hidi_
Hidi_OP2mo ago
switch between displays I assume?
b1mind
b1mind2mo ago
Christian Schaefer
CodePen
A CSS-only Carousel Slider
I've recently read about and discussed CSS Scroll Snapping so often that I felt like I should build a CSS-only carousel based on it. Here are a few th...
b1mind
b1mind2mo ago
There are lots of examples I would search and find* one you like. (more modern ones use modern css too)
Hidi_
Hidi_OP2mo ago
awesome, didn't know u could interact using just css (aside from buttons and links) or these use anchors I think I see thats interesting
b1mind
b1mind2mo ago
cool thing about that is url === best state so you could share the url with #anchor tag in it and it would be on that slide 🤔 thats actually dope af its kinda going ham by itself out of focus though 😂 so yea maybe learn from this, wouldn't copy it.
Hidi_
Hidi_OP2mo ago
yeah I think this one does that? https://codepen.io/skillthrive/pen/jOzVLGR
Skillthrive
CodePen
CSS Only Carousel
Simple image carousel using only HTML and CSS....
Want results from more Discord servers?
Add your server