HTML id attributes - HTML and XHTML attributes - Guide to HTML, XHTML Guide

Change Font Size: / / Directory List

HTML id attribute

Id attribute - a unique identifier for the element
  • Trackback Address: http://www.nt22.com/xhtml-html/attribute_id/

You may have several reasons for the use of the following attributes to id

  • You would like to link to a page designated location.
  • You have to a certain HTML elements on the use of a specific css style.
  • You want to use for each element HTML script (such as javascript)
  • You have to distinguish between two elements of the same HTML.

Example

  <div Id = "nt221" /> nt221 use to distinguish between the two and nt222 div tags <div> <div id = "nt222" /> nt221 use to distinguish between the two and nt222 div tags <div> 

Note

  • Id attribute with the same attribute name, the HTML4 attribute can be used in the document, the new web standards have abandoned this property. Therefore, the use of the name attribute should be used when XHTML transitional type definition (xhtml1-transitional.dtd) XHTML can not be used in the strict definition of type (xhtml1-strict.dtd).
  • Id attributes in the pages with CSS style sheets must be in the sole, the best in the entire site is unique.

Extended reading

Reference