HTML form
Form is used to collect different types of user input, a form composed of different types of labels, tags and associated attributes are used as follows:
1, <form> tag defines the entire form area
- action attribute defines the form data submitted address
- Way method attribute defines the form submission, generally "get" way and "post" mode
2, <label> tag is defined text label form element
3, <input> tag defines general form element
- Attribute value attribute value of the type defined in the form element
- type = "text" is defined single-line text input box
- type = "password" to define a password input box
- type = "radio" is defined radio button
- type = "checkbox" check box is defined
- type = "file" is defined to upload files
- type = "submit" button to submit definitions
- type = "reset" button to reset the definition
- type = "button" to define a common button
- type = "image" is defined as a picture submit button, with the src attribute definition picture address
- type = "hidden" defines a hidden form fields, used to store the value of
- The name attribute defines the name of the form element, this name is the key name when submitting data
4, <textarea> tag defines a multi-line text entry box
5, <select> tag defines the element drop down menu
6, <option> tag and <select> tag with the defined drop down menu options element
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表单html</title> </head> <body> <h1>注册表单</h1> <form action=" " method="get"> <div> <label for="username " </Username:>label> <input type="text" name="username" id="username"> </div> <br /> <div> <label for="password">密 码:</label> <input type="password" name="password" id="password"> </div> <br /> <div> <label>性 别:</label> <input type="radio" name="gender" value="0" id="male"> <label for="male">男</label> <input type="radio" name="gender" value="1" id = "female"> <label for="female">女</label> </div> <br /> <div> <label>爱 好:</label> <input type="checkbox" name="like" value="study"> 学习 <input type="checkbox" name="like" value="python"> python <input type="checkbox" name="like" value="frontend"> 前端 <input type="checkbox" name="like" value="beauty"> 美少女 </div> <br /> <div> <label>照 片:</label> <input type="file" name=""> </div> <br /> <div> <label><>label</Personal Jane Shao: textarea name="introduce"></textarea> </div> <br /> <div> <label>籍 贯:</label> <select name="site"> <option value="0">北京</option> <option value="1">上海</option> <option value="2">河南</option> <option value="3">湖北</option> <option value="4">云南</option> </select> </div> <br /> <div> <br> <input type="hidden" name="hid01" value="12"> </div> <br /> <div> <input type="submit" name="" value="提交"> <!-- <input type="image" src="images/goods.jpg" name=""> --> <input type="reset" name="" value="重置"> </div> </form> </body> </html>
E.g:
<form >
<div>
<label for="username">用户名:</label>
<input type="text" name="username" id="username">
</div>
</form>
<label for = "username"> and <input id = "username"> fit, click on the text can be selected.