HTML enctype 属性用于指定在将表单输入数据发送到服务器之前应如何对其进行编码。
如果 method 属性的值为 post 并且存在于 <form> 元素中,则使用此属性。此属性的默认值为“application/x-www-form-urlencoded”。
语法
以下是“enctype”属性的值
- text/plain:它用于调试目的。
- multipart/form-data:如果表单包含类型为 = file 的 <input> 元素,则使用该元素。
- application/x-www-form-urlencoded:它定义了所有字符在发送之前都经过编码。
这些值可以被 <button>、<input type = submit> 或 <input type = image> 元素上的 formenctype 属性覆盖。
适用于
下面列出的元素允许使用 HTML content 属性
元素 | 描述 |
---|---|
<form> | HTML<form>标签用于定义用于输入用户数据的应用程序表单。 |
HTML enctype 属性的示例
在以下示例中,我们在 <form> 元素中使用 HTML 'enctype' 属性,其值为 “text/plain”。
index.js
支持的浏览器
浏览器 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
是否支持 | Yes | Yes | Yes | Yes | Yes |