![]() |
Definition and UsageThe The Browser SupportSyntax
Attribute Values
|
Example:
HTML
<!DOCTYPE HTML>
<html>
<body>
<h1 id="myHeader">Hello World!</h1>
<button onclick="displayResult()">Change text</button>
<script>
function displayResult() {
document.getElementById("myHeader").innerHTML = "Have a nice day!";
}
</script>
</body>
</html>
Example:
HTML
<html>
<body>
<h2><a id="top">Some heading</a></h2>
<p>Lots of text....</p>
<p>Lots of text....</p>
<p>Lots of text....</p>
<a href="#top">Go to top</a>
</body>
</html>
Example:
HTML
<!DOCTYPE HTML>
<html>
<head>
<style>
#myHeader {
color: red;
text-align: center;
}
</style>
</head>
<body>
<h1 id="myHeader">Horje is the best!</h1>
</body>
</html>
html id attribute |
How to Use the id attribute to manipulate text with JavaScript | HTML Global Attributes |
How to Use the id attribute to link to an element with a specified id within a page | HTML Global Attributes |
How to Use the id attribute to style text with CSS | HTML Global Attributes |
Read Full: | HTML Global Attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Global Attributes |
Uploaded by: | Admin |
Views: | 30 |
Reffered: https://www.w3schools.com/tags/att_global_id.asp