id

How to Use id

You can define an id in your HTML by adding the id attribute to an element:

<div id="uniqueElement">This is a unique div.</div>

In your CSS, you can style the element using the hash (#) followed by the id name:

#uniqueElement { background-color: lightblue; }

Examples of id

Example 1: Basic Usage

This is a simple div with a unique id:

This div has an id of uniqueDiv.

Example 2: Targeting with CSS

The following example shows how to style an element with an id:

This text is styled using the #uniqueDiv id.

Example 3: Manipulating with JavaScript

This example demonstrates how you can manipulate an element with JavaScript:

Original content