htmlmeta-tags

How to include meta data in HTML tags


I plan to use a headless-CMS to manage content on my website, so a non-technical content editor will be able to independently maintain content.

To assist the content editor map content between the website and the CMS, I need to inject a CMS ID into HTML tags. (thinking that the content editor will view the page source to find the value)

What is the standard way to inject meta data into a HTML tag?

E.g. <p cms-id=7adQpNPZxP4jK28RLp3wES></p>


Solution

  • You can use data- attributes on elements. See Mozilla: Using data attributes for usage.

    It doesn't interfere with HTML semantics and is easily accessible with JavaScript.