class
class
全局属性 是元素的区分大小写的类的空格分隔列表。类允许 CSS 和 JavaScript 通过 类选择器 或 DOM 方法 document.getElementsByClassName
等函数选择和访问特定元素。
¥The class
global attribute is a space-separated list of the case-sensitive classes of the element. Classes allow CSS and JavaScript to select and access specific elements via the class selectors or functions like the DOM method document.getElementsByClassName
.
Try it
尽管规范没有对类的名称提出要求,但鼓励 Web 开发者使用描述元素语义用途的名称,而不是描述元素的表示形式。例如,attribute 用来描述属性而不是斜体,尽管此类的元素可以用斜体表示。即使页面的呈现方式发生变化,语义名称仍保持逻辑。
¥Though the specification doesn't put requirements on the name of classes, web developers are encouraged to use names that describe the semantic purpose of the element, rather than the presentation of the element. For example, attribute to describe an attribute rather than italics, although an element of this class may be presented by italics. Semantic names remain logical even if the presentation of the page changes.
规范
Specification |
---|
HTML Standard # global-attributes:classes-2 |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also