Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

ShadowRoot: innerHTML property

TheinnerHTML property of theShadowRoot interface gets or sets the HTML markup to the DOM tree inside theShadowRoot.

Note that some browsers serialize the< and> characters as&lt; and&gt; when they appear in attribute values (seeBrowser compatibility).This is to prevent a potential security vulnerability (mutation XSS) in which an attacker can craft input that bypasses asanitization function, enabling a cross-site scripting (XSS) attack.

Value

A string.

When set to thenull value, thatnull value is converted to the empty string (""), sosr.innerHTML = null is equivalent tosr.innerHTML = "".

Examples

Setting the innerHTML of a Shadow root

js
let customElem = document.querySelector("my-shadow-dom-element");let shadow = customElem.shadowRoot;shadow.innerHTML = "<strong>This element should be more important!</strong>";

Specifications

Specification
HTML
# dom-shadowroot-innerhtml

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp