Table of Contents
HTML form tag summary
To group related elements in the form, use
Home Web Front-end HTML Tutorial Summarize some uses of HTML form

Summarize some uses of HTML form

Jun 25, 2017 am 09:46 AM
form html form

HTML form tag summary

    最近研究 form标签,有一些小心得写下来与大家分享分享,共勉。在小结的最后有一个form表单的小例子,可以作为参考。                                                    -----DanlV
Copy after login


form是HTML的一个极为重要的功能标签之一。
Copy after login


##Input field input

  • input type The attributes have the following attribute values:

    1.button button (more details below)
    2.file is used for file selection
    3.hidden hidden field, which can realize hidden operations
    4.text Used for text input
    5.password input with password
    6.radio radio button, the same name attribute is a group
    7.checkbox multi-select button, the name attribute is the same group
    8.image image form submit button
    9.reset reset form button
    10.submit submit form button

  • alt attribute, defined when the button image , the alternative text of the slide

  • src attribute, which defines the link address of the image when the button is an image

  • checked attribute, which defines the default option

    The value of checked is true or false, or it can be written directly as checked

  • disabled attribute to disable the current Input field (usage as checked)

  • readonly attribute, read-only for the current input field, the actual function is the same as disabled, but the displayed effect is different (usage as checked)

  • maxlength attribute, defines the maximum length of input field characters

  • name attribute, defines the name of the current input field

  • value attribute, defines the default value of the current input field


Text input area textarea

  • rows attribute, specifies visible rows Number


  • cols attribute, specifies the number of visible columns


  • ##disabled attribute, disables the current text input area
  • name attribute, the name of the current text area
  • readonly attribute, the current text area is read-only
Button button

    There are three type types:
  • 1.type="button"General function button

    2.type="submit"Submit form form Function button
    3.type="reset"Reset form form function related function button


  • disabled attribute, disable this button
  • name attribute, the name of the button
  • value attribute, the default value of the text content displayed on the button
Down menu select

    Related attributes:
  • 1.disabled attribute, disable the menu

    2.multiple attribute, stipulates that multiple items can be selected at the same time
    3.name attribute, drop-down The name of the list
    4.size attribute, the number of visible items in the menu

  • ##Tag
  • , defines the option grouping of the drop-down list, the attribute is :

    5.label attribute, defines the label (name) of the option group, required attribute 6.disabled attribute, disabled

  • Attribute, defines the options in the drop-down list (this label is in the

    label), the attributes are: 1.disabled attribute, disables 2.label attribute, defines when using

    ##The label in the form

In order to make the input more user-friendly and improve the user experience, When clicking on the prompt text, the cursor will automatically focus on the input position. Use this label. There are two ways to use it:

    This method uses the for attribute of label, and the value specifies the name of the input area
  • Put the input directly into the label. There is no need to use the for attribute, which is recommended.

    ---Group related elements in the form fieldset

  • Label defines the group title. See the last code for relevant examples.

Code Example

        <form action="" method="post">
            <fieldset>
                <legend>天下第一争霸赛</legend>    
                    
            <label > 门派: <input type="text" name="menpai" id=""></label>
            <br><label >密码: <input type="password" name="psw" id="">    </label>
            <br><label >上传你的请柬: <input type="file" name="qingjian" id=""></label>
            <br>选武器: <input type="radio" name="arms" id="">刀
                        <input type="radio" name="arms" id="">剑
                        <input type="radio" name="arms" id="">枪
                        <input type="radio" name="arms" id="">鞭
            <br>挑战对手: <input type="checkbox" name="Army" id="">梅超风
                            <input type="checkbox" name="Army" id="">洪七
                            <input type="checkbox" name="Army" id="">金毛狮王谢逊
                            <input type="checkbox" name="Army" id="">张三丰
            <br><label > 选择你的门派:<select name="" id=""  >
                <optgroup label="西域">
                    <option value="天山">天山派</option>
                    <option value="昆仑">昆仑派</option>

                </optgroup>
                <optgroup label="中原" >
                    <option value="峨眉">峨眉派</option>
                    <option value="少林">少林派</option>
                    <option value="武当" selected>武当派</option>
                    <option value="天龙">天空派</option>
                    <option value="星宿">星宿派</option>
                    <option value="逍遥">逍遥派</option>
                    <option value="丐帮">丐帮派</option>
                    <option value="五毒">五毒派</option>
                    <option value="明教">明教派</option>
                </optgroup>


            </select></label>
            <br> <input type="image" src="" alt="假装有图片">
            <br> <input type="reset" value="重置"> <input type="submit" value="确定">
            </fieldset> 
        

        </form>
Copy after login

The above is the detailed content of Summarize some uses of HTML form. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles