1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
---
title: HTMLStyleElement
slug: Web/API/HTMLStyleElement
tags:
- API
- HTML DOM
- HTMLStyleElement
- Reference
translation_of: Web/API/HTMLStyleElement
---
<div>
<div>{{APIRef("HTML DOM")}}</div>
</div>
<p><strong><code>HTMLStyleElement</code></strong> 接口表示 {{HTMLElement("style")}} 元素。它从 {{domxref("HTMLElement")}} 和 {{domxref("LinkStyle")}} 中继承属性和方法。</p>
<p>这个接口不允许修改包含其中的CSS(大多数情况下)。如果需要修改CSS,前往<a href="https://developer.mozilla.org/zh-CN/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information">关于使用动态样式的信息</a>查看在DOM中用于修改特定CSS属性的对象。</p>
<p>{{InheritanceDiagram(600, 120)}}</p>
<h2 id="属性">属性</h2>
<p><em>Inherits properties from its parent, {{domxref("HTMLElement")}}</em><em>, and implements {{domxref("LinkStyle")}}</em><em>.</em></p>
<dl>
<dt>{{domxref("HTMLStyleElement.media")}}</dt>
<dd>Is a {{domxref("DOMString")}} representing the intended destination medium for style information.</dd>
<dt>{{domxref("HTMLStyleElement.type")}}</dt>
<dd>Is a {{domxref("DOMString")}} representing the type of style being applied by this statement.</dd>
<dt>{{domxref("HTMLStyleElement.disabled")}}</dt>
<dd>Is a {{domxref("Boolean")}} value representing whether or not the stylesheet is disabled (true) or not (false).</dd>
<dt>{{domxref("LinkStyle.sheet")}} {{readonlyInline}}</dt>
<dd>Returns the {{domxref("StyleSheet")}} object associated with the given element, or <code>null</code> if there is none</dd>
<dt>{{domxref("HTMLStyleElement.scoped")}} {{non-standard_inline}} {{obsolete_inline}}</dt>
<dd>Is a {{domxref("Boolean")}} value indicating if the element applies to the whole document (<code>false</code>) or only to the parent's sub-tree (<code>true</code>).</dd>
</dl>
<h2 id="方法">方法</h2>
<p><em>No specific method; inherits properties from its parent, {{domxref("HTMLElement")}}</em><em>, and {{domxref("LinkStyle")}}</em><em>.</em></p>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">注释</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG', "#htmlstyleelement", "HTMLStyleElement")}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5.1', "document-metadata.html#the-style-element", "HTMLStyleElement")}}</td>
<td>{{Spec2('HTML5.1')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', "document-metadata.html#the-style-element", "HTMLStyleElement")}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>The following property has been added: <code>scoped</code>.</td>
</tr>
<tr>
<td>{{SpecName('DOM2 HTML', 'html.html#ID-16428977', 'HTMLStyleElement')}}</td>
<td>{{Spec2('DOM2 HTML')}}</td>
<td>Added a second inheritence, the {{domxref("LinkStyle")}} interface.</td>
</tr>
<tr>
<td>{{SpecName('DOM1', 'level-one-html.html#ID-16428977', 'HTMLStyleElement')}}</td>
<td>{{Spec2('DOM1')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.HTMLStyleElement")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li>The HTML element implementing this interface: {{HTMLElement("style")}}.</li>
<li><a href="/en-US/docs/DOM/Using_dynamic_styling_information" title="DOM/Using_dynamic_styling_information">Using dynamic styling information</a> to see how to manipulate CSS.</li>
</ul>
|