How to use Id Attribute in HTML5

In this article I am going to explain about Id attribute.
  • 2006

Id Attribute in HTML5

The id attribute use for identify unique id for any HTML element. After defined id we can use this element by id. The id also used in style sheet for point to style sheet.

Browser that supports id Attribute

Internet explorer, Mozilla firefox, Google chrome, opera and Safari browsers.


<ElementName id="idName">


In this example "Hello" message will be display after clicking on button message will be change.



<script type="text/javascript">

    function myfun() {

        document.getElementById("htp").innerHTML = "Hello Friend";







<h1 id="htp">Hello</h1>

<button onclick="myfun()">click me</button>






Further Readings

You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here
© 2020 DotNetHeaven. All rights reserved.