Detailed explanation of the usage of form tag in HTML5

小云云
Release: 2018-03-05 14:50:03
Original
2535 people have browsed it

This article mainly shares with you the detailed usage of form tag in HTML5. I will share the usage of form with you with code examples. I hope it can help you.

Grammar:

Explanation: 1. appears in pairs, with Start and end with

, and the form must be placed between them.

2. Method transmission method, get/post is an issue that back-end programmers consider

3. action The data entered by the viewer is The place to send to, such as a php page, (save.php)

  1. ##< form   method="post"   action="save.php">

  2. ##            ##<

    label for="username">Username:label>

  3.         <input type="text" name="username" />  

  4.         <label for="pass">密码:label>  

  5.         <input type="password" name="pass" />  

  6. ##form>

Text input box, password input box

When the user needs to type letters, data, etc. in the form, the text input box is used. The text input box is also Can be converted into a password input box

Syntax:

  1. ##<form>

  2. ##<

    input type = "text/password" name = "Name" value = "Text" />

  3. #

    form > ##Explanation: 1.type:


When type is text, it is a text input box

When type is password, it is the password input box

2.name: Name the text box for use by background asp php

3.value: Set the default value for the text input box (generally used as a prompt)

  1. ##>

  2. #< html>

  3. ##<

    head>

  4. ##<
  5. meta http-equiv="Content-Type" content ="text/html; charset=utf-8">

  6. ##​ <title>Text input box, password input boxtitle>

  7. ##< ;/head>

  8. ##<

    body>

  9. ##<
  10. form method="post" action="save.php"> ## Account:

  11.     <input type = "text" name = "myName" />  

  12.     <br />  

  13.     密码:  

  14.     <input type = "password "  name = "pass"/>  

  15. form>  

  16. ##body>

  17. ##html>

Result:

Account:

Password:


Text field: supports multi-line text input

When the user needs to enter a large section of text in the form, text input is used Domain

Syntax:

##<

textarea rows = "Number of rows" cols = "Number of columns" > Text textarea> Explanation: 1. The text input field starts with


2.rows: Input The number of rows of the text input field

3.cols: Enter the number of columns of the text input field

##4.In