id attribute

The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element \ with the same id in an HTML document. the id attribute must be unique within the HTML document. The id name is case sensitive! The id name must contain at least one character, cannot start with a number, and must not contain whitespaces (spaces, tabs, etc.).

            <script>
                const x = document.getElementById("lion");
                // x = lion 
            </script>
<div id ="lion"> lion </div>


Back to