Language

HTML id


Id is an attribute of html. HTML element is selected using id attribute. Each id will have a new value that will not match any other id. An id will only select one element of the HTML. Multiple ids can be used on an HTML page, but the value of one id will not match the value of another id.


First place the id attribute in an element and then give a new value in that id attribute. The value of this id attribute is used to select the element. When this value is used, a (#) hashtag must be placed before this value. This hash indicates that it is an id.


There are two methods of using CSS with this id. First, within the <head> tag, we place the <style> tag, and within the <style> tag, we use it. The second one is, creating a CSS page and styling using id within it.

html id attribute

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #myId{
            text-align: center;
            color: rgb(50, 50, 175);
        }
    </style>
</head>
<body>
<h1 id="myId">myschoolhouse.in</h1>
</body>
</html>