HTML ID

Html id is a unique identification for an HTML element. If you want to identify just one element and its content then you should use id.
You can design a specific element by using the id value with CSS. The id value also used by CSS and JavaScript to perform certain task.

Example:

<!DOCTYPE html>
<html>
<head>
<title> Page Title </title>
</head>
<body>
<h1> This is id attribute example. </h1>
<h1 id="unique"> id attribute </h1>
</body>
</html>

Run Example

CSS with ID

In CSS to select the id of an element write a hash(#) character before the id name.

Example:

<style>
#id_name {
  color: red;
  background-color: lightblue;
  padding: 20px;
}

</style>

Run Example

JavaScript with ID

In CSS to select the id of an element write a hash(#) character before the id name.

Example:

<script>
function jsFunction() {
document.getElementById("myHeader").innerHTML= "This is JS with ID!";
}
</script>

Run Example