Search code examples
javascripthtmletag

Can html element have multiple values in etag attribute?


Our QA team use etags in our application for searching the right elements on the page.

<el etag="accordion.container">...</el>

So if the etag value is just a string, than can it have multiple values separated with whitespace ? Like this

<el etag="accordion.container user.info">...</el>

Or is it a bad practice ? If so, than why ?


Solution

  • Etag, as noted by the tag () you marked this question with, is an HTTP header.

    There is no etag attribute in HTML. Using non-standard attributes at all is bad practise.

    HTML provides data-* attributes for adding custom data to a document. Their values are custom and freeform so you could define a data-etag attribute as holding a space separated list of values. You would just need to ensure that the custom tooling you wrote for processing them expected them to hold that kind of value.