id
id
全局属性定义了一个全文档唯一的标识符(ID)。
尝试一下
<p>A normal, boring paragraph. Try not to fall asleep.</p>
<p id="exciting">The most exciting paragraph on the page. One of a kind!</p>
#exciting {
background: linear-gradient(to bottom, #ffe8d4, #f69d3c);
border: 1px solid #696969;
padding: 10px;
border-radius: 10px;
box-shadow: 2px 2px 1px black;
}
#exciting:before {
content: "ℹ️";
margin-right: 5px;
}
描述
规范
Specification |
---|
HTML # global-attributes:the-id-attribute-2 |
浏览器兼容性
参见
- 所有的全局属性。
- 反映该属性的
Element.id
。 Document.getElementById
方法。- CSS ID 选择器。