- id attribute specifies a unique id for an HTML element.
- id attribute must be unique within the HTML document.
- id attribute can be used by a JavaScript (via the HTML DOM) or by CSS to make changes or style the element with the specified id.
id usage :
<"element" id="value">
id value :
- id : Specifies a unique id for an element.
- Must begin with a letter A-Z or a-z
- Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
- Values are case-sensitive
id example:
| <html> <head> <script type="text/javascript"> function change_header() { document.getElementById("myHeader").innerHTML="some text 1"; } </script> </head> <body> <h1 id="myHeader">some text 2</h1> <button onclick="change_header()">Change text</button> </body> </html> |
origin by : w3schools.com


0 comments:
Post a Comment