HTML Id

HTML Id

It refers to a unique value for an HTML element. This HTML id value can be used with CSS and JavaScript to perform certain task.

if we want to select an element with a specific id, write a hash (#) character, followed by the id of the element.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML ID</title>
<style>
#subject {  
    background:#f8f8f8;  
    color:#888;  
    padding:5px;  
} 
</style>  
</head>
<body>
    <h1 id="subject">Html</h1>
    <p>Html stands for Hyper Text Markup Language.It is the standard markup language for creating web applications.</p>
    <h1 id="subject">Jquery</h1>
    <p>jQuery is a lightweight, "write less, do more", JavaScript library.</p>
 </body>
</html>

Difference between HTML Class and ID

HTML class name can be used by multiple elements while An HTML element can only have one unique id that belongs to that single element.