Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<shadow>

현재 번역은 완벽하지 않습니다. 한국어로 문서 번역에 동참해주세요.

개요

The HTML <shadow> element is used as a shadow DOM insertion point. You might use it if you have created multiple shadow roots under a shadow host. It is not useful in ordinary HTML. It is used with Web Components.

속성

This element includes the global attributes.

예제

Here is a simple example of using the <shadow> element. It is an HTML file with everything needed in it.

참고: This is an experimental technology. For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox.

<html>
  <head></head>
  <body>

  <!-- This <div> will hold the shadow roots. -->
  <div>
    <!-- This heading will not be displayed -->
    <h4>My Original Heading</h4>
  </div>

  <script>
    // Get the <div> above with its content
    var origContent = document.querySelector('div');
    // Create the first shadow root
    var shadowroot1 = origContent.createShadowRoot();
    // Create the second shadow root
    var shadowroot2 = origContent.createShadowRoot();

    // Insert something into the older shadow root
    shadowroot1.innerHTML =
      '<p>Older shadow root inserted by &lt;shadow&gt;</p>';
    // Insert into younger shadow root, including <shadow>.
    // The previous markup will not be displayed unless
    // <shadow> is used below.
    shadowroot2.innerHTML =
      '<shadow></shadow> <p>Younger shadow root, displayed because it is the youngest.</p>';
  </script>

  </body>
</html>

If you display this in a web browser it should look like the following.

shadow example

사양

사양 상태 주석
Shadow DOM
The definition of 'shadow' in that specification.
Working Draft  

브라우저 호환성성

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 35 28 (28) [1] Not supported 26 Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 37 28.0 (28) [1] Not supported ? ?

[1] If Shadow DOM is not enabled in Firefox, <shadow> elements will behave like HTMLUnknownElement. Shadow DOM was first implemented in Firefox 33 and is behind a preference, dom.webcomponents.enabled, which is disabled by default.

같이 보기

문서 태그 및 공헌자

 이 페이지의 공헌자: azunyan3
 최종 변경: azunyan3,