全局属性
Global attributes are attributes common to all HTML elements; they can be used on all elements, though they may have no effect on some elements.
Global attributes may be specified on all HTML elements, even those not specified in the standard. That means that any non-standard elements must still permit these attributes, even though using those elements means that the document is no longer HTML5-compliant. For example, HTML5-compliant browsers hide content marked as <foo hidden>…</foo>
, even though <foo>
is not a valid HTML element.
全局属性 | 说明 |
---|---|
accesskey | 指定访问元素的快捷键 |
autocapitalize | 用来控制文本在用户输入/编辑时的大小写 枚举属性 |
autofocus | 是否自动聚焦 布尔属性 |
class | 指定元素的类名(classes)列表 |
contenteditable | 是否允许用户编辑内容 枚举属性 |
data-* | 自定义数据属性 |
dir | 指定元素文本内容的对齐方向 枚举属性 |
draggable | 是否允许用户拖拽元素 枚举属性 |
enterkeyhint | 用于定义要为虚拟键盘上的回车键显示的操作标签(或图标) 枚举属性 |
exportparts | |
hidden | 是否隐藏当前元素 布尔属性 |
id | 为元素指定唯一的 id |
inert | 指示浏览器将忽略该元素 布尔属性 |
inputmode | 虚拟键盘应该显示何种类型的键盘 枚举属性 |
is | |
itemid | |
itemprop | |
itemref | |
itemscope | |
itemtype | |
lang | 指定元素的语言 |
nonce | |
part | |
popover | |
slot | |
spellcheck | 是否对元素进行拼写检查 枚举属性 |
style | 指定元素的内联样式 |
tabindex | 指定元素的 tab 顺序 |
title | 指定元素额外的信息 |
translate | 是否翻译当前元素 枚举属性 |