0% found this document useful (0 votes)
2 views

59. Id Attribute

The id attribute in HTML specifies a unique identifier for elements, which must be unique within the document and can be used for styling and JavaScript manipulation. It must start with a letter, cannot contain spaces, and can include letters, digits, hyphens, and underscores. Examples are provided to illustrate the use of the id attribute in HTML elements and CSS styling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

59. Id Attribute

The id attribute in HTML specifies a unique identifier for elements, which must be unique within the document and can be used for styling and JavaScript manipulation. It must start with a letter, cannot contain spaces, and can include letters, digits, hyphens, and underscores. Examples are provided to illustrate the use of the id attribute in HTML elements and CSS styling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Id Attribute

The id attribute specifies a unique id for an HTML element. The value must be
unique within the HTML document.
The id attribute is most used to point to a style in a style sheet, and by
JavaScript (via the HTML DOM) to manipulate the element with the specific
id. The id attribute can be used on any HTML element.
Rules
• Must begin with a letter A-Z or a-z
• A class name cannot start with a number
• Must not contain any space characters
• Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and
underscores ("_")
• In HTML, all values are case-insensitive
<html>
<head>
<title> www.geekyshows.com </title>
</head>
<body>
<a href="#imp">Important</a>
<p id="top">
Once upon a time, all the birds - the swans, cranes, </p>
<h3 id="imp">
Goodwill is that unseen force which is </h3>
<p>He has neither the time, nor the interest to bother </p>
<a href="#top">Go to Top</a>
</body>
</html>
<html>
<head>
<style>
#geekyshows {
color: red; font-size: 60px;
}
</style>
</head>
<body>
<p id="geekyshows">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>

You might also like