Guides

Inner HTML

How to add inner html to tags.

For tags that set inner content, such as <style> and <script>, you can set the inner content using the textContent or innerHTML properties.

When using textContent the content will have simple sanitisation applied server side. Client side it will use the element.textContent setter.

⚠️ When using innerHTML the content will not be sanitised. Client side it will use the element.innerHTML setter. Make sure you sanitise user input if providing it with this property.

Note: children is an alias for innerHTML and is deprecated.

Example

useHead({
  style: [
    {
      innerHTML: 'body {color: red}',
    },
  ],
  noscript: [
    {
      textContent: 'Javascript is required',
    },
  ],
})