XHTML » XHTML Core Tag » id

Syntax:
id="name"

The id attribute is used to assign a identifier value to a tag. Each id must be unique within the document and each element can only have one id.

In XHTML, the id attribute has essentially replaced the use of the name attribute. The value of the id must start with an alphabetic letter or an underscore. The rest of the value can contain any alpha/numeric chacracter.
 
Because it is unique, the value of the id can be the target of a URL or used to define a style rule.
 
There are four attributes common to most tags: class, id, style, and title.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML id attribute Example</title>
</head>
<body>
<a href="#ckbx2">Go to Check Box Two</a>
<br />
<input type="checkbox" id="ckbx1" /> Check Box One
<br />
<input type="checkbox" id="ckbx2" /> Check Box Two
<p id="_mytext">
How now purple cow?
</p>
</body>
</html>
Explanation:

The use of id does not effect the output in any manner.

Language(s): XHTML