No Special Characters In Tag Names

ID

html.tagname_specialchars

Severity

low

Remediation Complexity

low

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Html

Tags

reliability

Description

Flags an opening element whose tag name contains a character outside the [A-Za-z0-9-] set, such as an underscore, $ or ..

Rationale

Custom element names must be lowercase, must contain a hyphen and may only use the characters the spec allows. An underscore or other special character yields a name the browser does not recognise as a valid custom element, so it falls back to an unknown element with no upgrade and unpredictable behaviour.

<my_component>x</my_component>    <!-- FLAW — underscore is not allowed -->

<my-component>x</my-component>    <!-- OK — hyphen-separated custom element -->

Remediation

Rename the element to use only letters, digits and hyphens; separate words with a hyphen instead of an underscore or other special character.