Id
Definition: In HTML markup formatting, the id
attribute is a unique identifier assigned to an element within a web page.
Usage: The id
attribute is commonly used to target specific elements when applying CSS styles or JavaScript interactions. It helps in distinguishing individual elements from one another within the page.
Syntax: The id
attribute is added to an HTML element using the following syntax:
<element id="unique-identifier">Content</element>
Example:
<p id="intro">This is the introduction paragraph.</p>
<div id="main-content">This is the main content of the page.</div>
<button id="submit-btn">Submit</button>
Note: The identifier specified in the id
attribute must be unique within the entire HTML document, hence it should not be repeated on other elements.