I noticed that in the Container settings you can set the HTML Tag to âCustomâ and manually type a tag name (for example âheroâ).
This made me wonder what the best practice is from a semantic HTML perspective.
For example, one could technically do this:
Tag: Custom
hero
which would output:
<hero>
However, my understanding is that this is not standard HTML, and browsers and search engines will simply treat it as an unknown element.
Because of that, it seems more correct to instead use a valid semantic HTML element and describe the type of section using a class.
For example:
Tag: Section
Class: hero
which outputs:
<section class="hero">
This seems to follow normal modern web development practices where:
section = semantic content block
class = describes the type of section (hero, products, benefits, etc.)
So my question is:
Is the recommended approach in Elements to keep using standard semantic tags like section, header, nav, main, etc., and then specify the purpose of the section through classes?
Or is there any advantage to using Custom tags for things like hero sections?
Iâm mainly thinking about semantic HTML, SEO, and accessibility best practices.
Iâm not an SEO expert, so would need to google and research exactly what tags youâd need to use⌠but Iâm pretty sure youâd be able to do exactly what you need in Elements. If there is a missing feature we can get it added in!
Perhaps ask one of the AI bots for advice on this, let me know how you get on.
Is the menu component marked with ânavâ as default because there is no way to mark it under advanced. It would save alot of work not have to put it in a container and then mark it.
In HTML, semantics come from the element type, not from its classes. Classes only provide hooks for styling or JavaScript, browsers and assistive technologies donât interpret them as carrying any meaning.
The custom tag option is there for when you need a tag not available in the dropdown, there are plenty of standard HTML elements you might want to reach for.
Youâre right that <hero> on its own isnât standard HTML. That said, the custom tag feature does have a legitimate use case: defining custom elements, which are part of a web standard called Web Components. Modern browsers let developers create their own HTML tags, as long as they follow the naming convention of including a hyphen, for example:
<hero-banner></hero-banner>
Custom elements can be wired up to JavaScript to behave like fully-featured components with their own logic and lifecycle, though thatâs probably outside the scope of this thread. More info here: Using custom elements - Web APIs | MDN
Using semantic tags is definitely the right approach. Just keep in mind that classes carry no semantic weight for browsers, screen readers, or other assistive technologies, theyâre purely for styling and JavaScript hooks.
I pulled in a container from the containers and it is set to width (Breakpoint) and Content alignment to Aligh center and and justify center. And the spacing is enabled. If I was to use the container only to mark the content as Main, which settings would be best. I have som contetn going full width so I need it to go full width but what about the other settings?
I just took a standard container and named it Main (plus of course HTML tagged it Main) and then put the top containers inside (not the menu). Same with the Footer. No extra settings. ChatGPT has good info.