如何在 HTML 中新增一個按鈕?
在 HTML 中使用 <button> 標籤來新增一個按鈕。HTML <button> 標籤用於在 HTML 表單中建立按鈕。你也可以使用 <input> 標籤來建立類似的按鈕。
<button> 標籤的屬性如下:
| 屬性 | 值 | 描述 |
|---|---|---|
| autofocus | 自動聚焦 | 指定按鈕在頁面載入時應具有輸入焦點。 |
| disabled | 停用 | 指定按鈕被停用。 |
| form | form_id | 指定按鈕所屬的表單。 |
| formaction | URL | 指定表單提交到的連結。 |
| formenctype | application/x-www-form-urlencoded multipart/form-data text/plain | 指定在將表單資料傳送到伺服器之前如何對其進行編碼。 |
| formmethod | get post | 指定如何傳送表單資料。 |
| formnovalidate | formnovalidate | 指定表單資料不應被驗證。 |
| formtarget | _blank _self _parent _top | 指定響應應在何處驗證。 |
| 名稱 | 名稱 | 指定按鈕名稱。 |
| 型別 | button reset submit | 指定按鈕型別。 |
| 值 | 文字 | 指定按鈕的初始值。 |
示例
您可以嘗試執行以下程式碼在 HTML 中實現 <button> 標籤:
<!DOCTYPE html> <html> <head> <title>HTML Button Tag</title> </head> <body> <form> <button name = "button" value = "OK" type = "button">My Button</button> </form> </body> </html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP