- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add a unique id for an element in HTML?
Use the id attribute in HTML to add the unique id of an element.
Example
You can try to run the following code to implement id attribute −
<html> <body> <h1>Tutorialspoint</h1> <p id = "myid">We provide Tutorials!</p> <button onclick = "display()">More...</button> <script> function display() { document.getElementById("myid").innerHTML = "We provide learning videos as well"; } </script> </body> </html>
Advertisements