[Web preliminary] form

input control

<input type="属性值" value="你好">

Insert picture description here

  1. type attribute

    By changing the value of this attribute, you can determine which input form you belong to.

  2. value attribute value

    value The text value. Some forms display a few words by default as soon as they open the page, which can be set by this value.

  3. name attribute

    • The value behind the name attribute is defined by ourselves.

    • If radio is a group, we must give them the same name name so that you can choose one of multiple

    <input type="radio" name="sex" /><input type="radio" name="sex" />
  4. checked attribute

    Indicates the default selection state. It is more common in radio buttons and check buttons.

label

The label tag defines a label (label) for the input element.

When we click on the text in the label, the cursor will be positioned in the specified form

  1. The first usage is to use the label to directly include the input form.
<label> 用户名: <input type="radio" name="usename" value="请输入用户名">   </label>

Suitable for single form selection

  1. The second usage for attribute specifies which form element the label is bound to.
<label for="sex"></label>
<input type="radio" name="sex"  id="sex">

textarea control (text field)

<textarea >
  文本内容
</textarea>

select drop-down list

<select>
  <option>选项1</option>
  <option>选项2</option>
  <option>选项3</option>
  ...
</select>

When selected = "selected" is defined in option, the current item is the default selected item

form field

Pass the collected user information to the server through the form form field

<form action="url地址" method="提交方式" name="表单名称">
  各种表单控件
</form>
Attributes Attribute value effect
action url address Used to specify the URL address of the server program that receives and processes the form data.
method get/post It is used to set the submission method of form data.
name name Used to specify the name of the form to distinguish multiple forms on the same page.
163 original articles published · Like 18 · Visitor 7684

Guess you like

Origin blog.csdn.net/xcdq_aaa/article/details/105363957