Is there any meainingless HTML tag should I use to carry additional meta data, for example attributes for JavaScript for specified block/area ? like:
<div class="item">
<meaninglesselement data-id="123">
<meaninglesselement data-type="sometype">
<meaninglesselement data-validate="true">
...
</div>
I know that I can move data-*
attributes to div class="item"
but I want a solution for clean code, even if there will be a lot of parameters.
If it is meta data for the whole document that might be useful for visitors or bots, you should use the
meta
element. You may only use defined or registeredname
values (but you could register new ones in the wiki).For meta data that is only needed for your scripts etc., you may use
data-*
attributes on existing elements (e.g.body
) or you may use thescript
element:You can place this element in the
head
or in the document body where phrasing content (likespan
) can be used, too.There is an informative example for the use as data block (instead of script):
So you could use HTML or JSON or whatever format you need.
If you'd want to use HTML, it may (***) look like:
*** (I'm not sure if it has to be a "full" conforming HTML document or if "snippets", like in my example, are allowed, too)
The data applies to the div, the attributes should be on the div. If you want to format your code with one item per line, then you can.
There are no elements designed for storing meta data that go in the document body.