aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/global_attributes/class
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/html/global_attributes/class
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/html/global_attributes/class')
-rw-r--r--files/zh-cn/web/html/global_attributes/class/index.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/files/zh-cn/web/html/global_attributes/class/index.html b/files/zh-cn/web/html/global_attributes/class/index.html
new file mode 100644
index 0000000000..61e6611ca5
--- /dev/null
+++ b/files/zh-cn/web/html/global_attributes/class/index.html
@@ -0,0 +1,59 @@
+---
+title: class
+slug: Web/HTML/Global_attributes/class
+tags:
+ - Global attributes
+ - HTML
+translation_of: Web/HTML/Global_attributes/class
+---
+<div>{{HTMLSidebar("Global_attributes")}}</div>
+
+<p><a href="/zh-CN/docs/Web/HTML/Global_attributes">全局属性</a> <strong>class </strong>的值是一个以空格分隔的元素的类名(classes )列表,它允许 CSS 和 Javascript 通过类选择器 (<a href="/zh-CN/docs/Web/CSS/Class_selectors">class selectors</a>) 或DOM方法( {{domxref("document.getElementsByClassName")}})来选择和访问特定的元素。</p>
+
+<div>{{EmbedInteractiveExample("pages/tabbed/attribute-class.html","tabbed-standard")}}</div>
+
+<p class="hidden"> </p>
+
+<p>尽管对class 的命名没有要求,但 web 开发者最好使用可以表达元素语义目的的名称,而不是描述元素展现的名称(即使一个元素是斜体,但是 class 的命名也不应该是 italics)。<strong>语义化</strong>命名即使在页面展现发生改变时仍能合乎逻辑。</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', "elements.html#classes", "class")}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>No change from latest snapshot, {{SpecName('HTML5.1')}}</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5.1', "elements.html#classes", "class")}}</td>
+ <td>{{Spec2('HTML5.1')}}</td>
+ <td>Snapshot of {{SpecName('HTML WHATWG')}}, no change from {{SpecName('HTML5 W3C')}}</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C', "elements.html#classes", "class")}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>Snapshot of  {{SpecName('HTML WHATWG')}}. From {{SpecName('HTML4.01')}}, <strong>class</strong> is now a true global attribute.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML4.01', "struct/global.html#h-7.5.2", "class")}}</td>
+ <td>{{Spec2('HTML4.01')}}</td>
+ <td>Supported on all elements but {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("head")}}, {{HTMLElement("html")}}, {{HTMLElement("meta")}}, {{HTMLElement("param")}}, {{HTMLElement("script")}}, {{HTMLElement("style")}}, and {{HTMLElement("title")}}.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("html.global_attributes.class")}}</p>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li>所有<a href="/zh-CN/docs/Web/HTML/Global_attributes">全局属性</a>。</li>
+</ul>