Home  >  Article  >  Web Front-end  >  What does id mean in html

What does id mean in html

WBOY
WBOYOriginal
2022-01-10 16:20:1212455browse

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.

What does id mean in html

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&gt ;, 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">&lt;element id=&quot;id&quot;&gt;</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">&lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;title&gt;123&lt;/title&gt; &lt;script&gt; function displayResult() { document.getElementById(&quot;myHeader&quot;).innerHTML=&quot;Have a nice day!&quot;; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 id=&quot;myHeader&quot;&gt;Hello World!&lt;/h1&gt; &lt;button onclick=&quot;displayResult()&quot;&gt;编辑文本&lt;/button&gt; &lt;/body&gt; &lt;/html&gt;</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