HTML | DOM Kbd Object
The Kbd Object in HTML DOM is used to represent the HTML <kbd> element. The <kbd> tag is the phrase tag and used to define the keyboard input. The text enclosed by <kbd> tag is typically displayed in the browser’s default monospace font. The <kbd> element can be accessed by using getElementById() method.
Syntax:
document.getElementById("ID")
Where ID is assigned to the <kbd> tag.
Example 1:
<!DOCTYPE html> <html> <head> <title> HTML DOM Kbd Object </title> </head> <body style = "text-align:center;"> <h1 style = "color:green;"> GeeksForGeeks </h1> <h2>DOM Kbd Object</h2> <kbd id = "GFG"> GeeksforGeeks:A computer Science Portal for Geeks </kbd> <br><br> <button onclick = "myGeeks()"> Submit </button> <script> function myGeeks() { var txt = document.getElementById("GFG"); txt.style.color = "red"; txt.style.fontSize = "25px"; } </script> </body> </html> |
Output:
Before Click on the button: :

After Click on the button:

Exaqmple 2: Kbd Object can be created by using the document.createElement Method.
<!DOCTYPE html> <html> <head> <title> HTML DOM Kbd Object </title> </head> <body style = "text-align:center;"> <h1 style = "color:green;"> GeeksForGeeks </h1> <h2>DOM Kbd Object</h2> <button onclick = "myGeeks()"> Submit </button> <script> function myGeeks() { var ele = document.createElement("KBD"); var txt = document.createTextNode("GeeksforGeeks:A" "computer Science Portal for Geek"); ele.appendChild(txt); document.body.appendChild(ele); } </script> </body> </html> |
Output:
Before Click on the button:

After Click on the button:

Supported Browsers: The browser supported by DOM Kbd Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Object Object
- HTML | Object tag
- HTML | DOM Ol Object
- HTML | DOM Bdo Object
- HTML | DOM Div Object
- HTML | DOM Pre Object
- HTML| DOM HR Object
- HTML | DOM Map Object
- HTML | DOM Nav Object
- HTML DOM Aside Object
- HTML | DOM S Object
- HTML | DOM BR Object
- HTML | DOM DFN Object
- HTML| DOM Ins Object
- HTML | DOM dl Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



