Search code examples
javascripthtmldommeta-tags

Meta Tag in Body


I'm implementing a system for my customer along the lines of attaching a tracking element to the DOM whenever specific errors are thrown (it simply has to have a certain value in a data-trkError attribute). My first thought was to use a

<span data-trkError="BLAH" style="display: none;"></span>

But then it occurred to me that this feels intuitively like what the meta tag should be usable for. However, this pretty much needs to be appended to a specific div in the DOM, ie within the body. Is this a problem? Is there anything standard-breaking or not-best-practises about a meta tag in the body tree?

Cheers


Solution

  • The <meta>-tag is part of the 4.2 Document metadata. Therefor it can only appear in the <head>-section of a document. Your solution using a <span> or a <div> or even a list for multiple errors is just fine for your purpose.