In HTML, id is the abbreviation of "Identity document", which means "identity identification number". This attribute is used to specify the unique id of the element. This attribute can be used as a link anchor, through JavaScript or through CSS changes or adds styles to elements with specified ids.
The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.
What does id mean in html
The id attribute specifies the unique id of the HTML element.
id must be unique within the HTML document.
The id attribute can be used as a link anchor to change or add styles to an element with a specified id via JavaScript (HTML DOM) or via CSS.
Differences between HTML 4.01 and HTML5
In HTML5, the id attribute can be used on any HTML element (it will validate any HTML element. But it is not necessarily useful).
In HTML 4.01, the id attribute cannot be used for: ,
, ,
,
, <script>, <style> ;, and <title>. <p>Note: HTML 4.01 has strict restrictions on id values (for example: in HTML 4.01 id values cannot start with a number). <p>Syntax<pre class="brush:html;toolbar:false"><element id="id"></pre><p>Attribute value<p>id specifies the unique id of the element. <p>Naming rules: <ul style="list-style-type: disc;"><li><p>Must start with the letters A-Z or a-z<li><p>Following characters: letters (A-Za -z), numbers (0-9), hyphens ("-"), underscores ("_"), colons (":") and periods (".")<li><p> Values are case sensitive <p> Examples are as follows: <pre class="brush:html;toolbar:false"><html>
<head>
<meta charset="utf-8">
<title>123</title>
<script>
function displayResult()
{
document.getElementById("myHeader").innerHTML="Have a nice day!";
}
</script>
</head>
<body>
<h1 id="myHeader">Hello World!</h1>
<button onclick="displayResult()">编辑文本</button>
</body>
</html></pre><p>Output results: <p>Before clicking the button<p><img src="https://img.php.cn/upload/image/805/355/789/1641802775925527.png" title="1641802775925527.png" alt="What does id mean in html"/> <p>After clicking the button<p><img src="https://img.php.cn/upload/image/891/705/104/1641802783118131.png" title="1641802783118131.png" alt="What does id mean in html"/><p> Recommended tutorial: "<a href="//m.sbmmt.com/course/list/11.html" target="_blank" textvalue="html视频教程">html video tutorial"</script>
The above is the detailed content of What does id mean in html. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn