如何在 HTML 中添加按钮?
htmlweb developmentfront end technology更新于 2024/7/31 11:56:17
使用 HTML 中的 <button> 标签添加按钮。HTML <button> 标签用于在 HTML 表单中创建按钮。您也可以使用 <input> 标签创建类似的按钮。
以下是 <button> 标签的属性 −
| 属性 |
值 |
描述 |
|---|---|---|
| autofocus |
Autofocus |
指定按钮在页面加载时应具有输入焦点。 |
| disabled |
Disabled |
指定按钮已禁用。 |
| form |
form_id |
指定按钮所属的表单。 |
| formaction |
URL |
指定表单提交的链接。 |
| formenctype |
application multipart/form-data text/plain |
指定表单数据在发送到服务器之前的编码方式。 |
| formmethod |
get post |
指定如何发送表单数据。 |
| formnovalidate |
Formnovalidate |
指定不应验证表单数据。 |
| formtarget |
_blank _self _parent _top |
指定响应的验证位置。 |
| Name |
Name |
指定按钮名称。 |
| Type |
button reset submit |
指定按钮类型。 |
| Value |
Text |
指定按钮的初始值。 |
示例
您可以尝试运行以下代码,在 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>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

