我正在读这个 basic tutorial on canvas
elements .以下句子中的 (almost)
引起了我的注意:
The id attribute isn't specific to the element but is one of the default HTML attributes which can be applied to (almost) every HTML element
哪些html元素不能接受id?
最佳答案
来自 w3schools (是的,我知道……):
Note: The id attribute is not valid in:
<base>
,<head>
,<html>
,<meta>
,<param>
,<script>
,<style>
, and<title>
.
请注意,这仅对 HTML4 有效,但这解释了本教程的“几乎”内容。
正如其他人所指出的,HTML5 接受所有元素的 id。
关于html - 哪些 DOM 元素不能接受 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11107463/