如何在 HTML 中使用 標籤對鍵盤輸入格式進行設定?
我們使用 <kbd> 標籤來定義鍵盤輸入。它是一個短語標籤,用於識別表示使用者鍵盤輸入的文字。其中的內容在大多數瀏覽器中顯示為預設等寬字型。我們可以使用樣式表覆蓋字型。
語法
<kbd> Keyboard text…
示例 1
以下是在 HTML 中使用 <kbd> 標籤的示例 -
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <p> Open a new file using the keyboard shortcut <kbd>Ctrl</kbd> + <kbd>N</kbd> </p> <p>Press<kbd>Ctrl </kbd> + <kdb>C </kdb>to copy text from the file.</p> <p>Press<kbd>Ctrl </kbd> + <kdb>P </kdb>to paste text to the file.</p> </body> </html>
示例 2
此標籤可以在 html 文件中使用,如下 -
<html> <body> <p>Two special keys in keyboard are:<kbd>ctrl</kbd>, <kbd>alt</kbd>.</p> </body> </html>
示例 3
我們還可以在 HTML 文件中為鍵盤值新增樣式。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> kbd { border-radius: 2px; padding: 2px; border: 1px solid black; } </style> </head> <body> <p> Open a new file using the keyboard shortcut <kbd>Ctrl</kbd> + <kbd>N</kbd> </p> <p>Press<kbd>Ctrl </kbd> + <kdb>C </kdb>to copy text from the file.</p> <p>Press<kbd>Ctrl </kbd> + <kdb>P </kdb>to paste text to the file.</p> </body> </html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP