Robert
Robert

Reputation: 190

Custom HTML DOM elements html validation

I am building a image slider with custom html elements. It is supported by the most of browsers but there is also an library for those that doesn't "document-register-element.js"

It works as expected.

The question i have is, is this is valid?

For example i have this custom element in HTML <cp-slider></cp-slides>

In the javascript it is registered as an HTML Element document.registerElement('cp-slider', {prototype: proto});

Here https://validator.w3.org/ it shows is as an error. But it doesn't check the JS of the file. So should i avoid custom DOM elements? Or in the "real validation (by google perhaps for SEO)" it wont be an issue?

Thank you!

Upvotes: 1

Views: 485

Answers (1)

master565
master565

Reputation: 795

It's bound to show an error in the validation site because it is likely only checking the standard HTML syntax. You shouldn't necessarily avoid custom DOM elements, they're very useful in some cases. The framework AngularJS allows you to smoothly define such custom elements (known as directives). This may or may not affect your SEO, depending on what is hidden. Google supposedly can infer some details, but you'll have to see what happens in your particular case.

Upvotes: 1

Related Questions