html中表單元素
1)<input>元素 (1) The <input> Element)
The <input> element is used to get input from the user in an HTML form.
<input>元素用于以HTML形式從用戶獲取輸入。
<input> tag is used to get input using input element, the type attribute of the input element is used to define inputs of multiple types in HTML.
<input>標記用于使用input元素獲取輸入,input元素的type屬性用于定義HTML中多種類型的輸入。
Syntax:
句法:
<input name="email" type="text" />
For the input element there are more values which will be discussed later.
對于輸入元素,還有更多值,將在后面討論。
2)<select>元素 (2) The <select> Element)
The select element is used to define the drop-down list (select Box) in the HTML form.
select元素用于定義HTML表單中的下拉列表(選擇框)。
The <select> tag is used to define the list. Also, two more tags are required with the <select> tag for the work. They are <value> and <selected>.
<select>標記用于定義列表。 此外,還需要兩個標簽以及<select>標記才能進行工作。 它們是<value>和<selected> 。
The <value> tag defines an option that can be selected in the drop-down list.
<value>標記定義了一個可以在下拉列表中選擇的選項。
The <selected> tag is used to define the element which is preselected in the form. By default, if no option is marked selected the first element is selected.
<selected>標簽用于定義在表單中預先選擇的元素。 默認情況下,如果未標記任何選項,則選擇第一個元素。
Syntax:
句法:
<select name="bikes">
<option value="value" selected> text </option>
. . .
</select>
In select tags, you can also select the number of options that are visible directly to the user without clicking on dropdown.
在選擇標簽中,您還可以選擇直接對用戶可見的選項數量,而無需單擊下拉菜單。
This is done by using the size attribute.
這是通過使用size屬性來完成的。
Syntax:
句法:
<select name="name" size="3"> ... </select>
This will show 3 options directly.
這將直接顯示3個選項。
In the select box, the user is allowed to select more that one (multiple) options. This is done by adding multiple attributes.
在選擇框中,允許用戶選擇一個以上(多個)選項。 這可以通過添加多個屬性來完成。
Syntax:
句法:
<select multiple> ... </select>
3)<textarea>元素 (3) The <textarea> Element)
The <textarea> element is used to define the text area input i.e. a multi-line input field in the HTML form.
<textarea>元素用于定義文本區域輸入,即HTML表單中的多行輸入字段。
This element needs the rows and cols attribute to be defined to set the number of rows and columns the <textarea> will occupy.
該元素需要定義rows和cols屬性,以設置<textarea>將占用的行數和列數。
Syntax:
句法:
<textarea rows="5" cols="10"> text_to_displayed </textarea>
The dimensions of the <textarea> can also be defined using stylesheet in HTML.
<textarea>的尺寸也可以使用HTML中的樣式表定義。
Syntax:
句法:
<textarea style="width:100px; height: 250px;"> text_to_displayed </textarea>
4)<Button>元素 (4) The <Button> Element)
The <button> element is HTML form is used to add a button to the form that can be clicked to perform actions in the form.
<button>元素是HTML表單,用于向表單添加按鈕,可以單擊該按鈕以執行表單中的操作。
Syntax:
句法:
<button type="button" onclick="action_performed"> text </button>
5)<datalist>元素 (5) The <datalist> Element)
The <datalist> element in HTML form is used to define a list of data elements that are predefined for the input element. It will create a drop-down of all the input options available.
HTML形式的<datalist>元素用于定義為輸入元素預定義的數據元素列表。 它將創建所有可用輸入選項的下拉列表。
To connect the <input> element to the <datalist>, the id of the datalist is to be referred by the list attribute of the input tag.
要將<input>元素連接到<datalist> ,該數據列表的id將由輸入標簽的list屬性引用。
Syntax:
句法:
<input list="datalist_id"/>
<datalist="datalist_id">
<option>... </option>
<option>... </option>
<option>... </option>
</datalist>
6)<output>元素 (6) The <output> Element)
The <output> element in HTML form is used to return the result of some calculations that are done in realtime in the form.
HTML表單中的<output>元素用于返回以該表單實時完成的一些計算的結果。
<output> tag is used to define the output. Also, one on the input tag is used to define the operation.
<output>標記用于定義輸出。 另外,輸入標簽上的一個用于定義操作。
Syntax:
句法:
<oninput="output_name.value= parseInt(input1.value) * parseInt(input2.value) "> 0
<input name="input1">
<input name="input2">
<output name="output_name" for="input1 input2"></output>
翻譯自: https://www.includehelp.com/html/form-elements.aspx
html中表單元素