Output:<\/strong><\/p>\n<\/p>\n2. “” element<\/h4>\n?<\/strong>This element is an inline element and belongs to the form-element group.<\/p>\nSyntax:<\/strong><\/p>\n\nInput name: \nInput age: \n\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n 国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂\n\nInput name: \nInput age: \n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
<\/p>\n
?<\/strong>This element is an inline element and belongs to the form-element group.<\/p>\nSyntax:<\/strong><\/p>\n\nInput name: \nInput age: \n\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n 国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂\n\nInput name: \nInput age: \n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Syntax:<\/strong><\/p>\n\nInput name: \nInput age: \n\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n 国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂\n\nInput name: \nInput age: \n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n 国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂\n\nInput name: \nInput age: \n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n 国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂\n
Output:<\/strong><\/p>\n? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
? ? ? ?<\/strong><\/p>\n3. “” element<\/h4>\nIt usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\nSyntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.<\/p>\n
Syntax:<\/strong><\/p>\n\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\n\n\n\n\n<\/datalist><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\n\n\n\n\n\n\n\n\n<\/datalist>\n\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\n
Output:<\/strong><\/p>\n<\/p>\n4. “” element<\/h4>\nThis element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\nSyntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is basically used to group related elements in forms and draws a box around similar elements.<\/p>\n
Syntax:<\/strong><\/p>\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Output:<\/strong><\/p>\n<\/p>\n5. “” element<\/h4>\nThis element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\nSyntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.<\/p>\n
Syntax:<\/strong><\/p>\n<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
<\/code><\/p>\nCodes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\n\nUsername: \n\n<\/form>\nThe below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
The below mentioned keygen field is outside of the form, but it's still a part of the above form.<\/p>\nEncryption: \n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Output:<\/strong><\/p>\n<\/p>\n6. “” element<\/h4>\nThis element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.<\/p>\n
Syntax:<\/strong><\/p>\n ... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
... <\/label><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\nExample of HTML label tag<\/title>\n<\/head>\n\n\n\nBoy<\/label>\n\nGirl<\/label>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\nExample of HTML label tag<\/title>\n<\/head>\n\n
Output:<\/strong><\/p>\n<\/p>\n7. “” element<\/h4>\nThis element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element.<\/p>\nSyntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element actually defines a caption for a
Syntax:<\/strong><\/p>\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset><\/pre>\nCodes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nCelebrity:<\/legend>\nName: \nPhone: \nAge: \n<\/fieldset>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n
Output:<\/strong><\/p>\n<\/p>\n8. “” element<\/h4>\nThis element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\nSyntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.<\/p>\n
Syntax:<\/strong><\/p>\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select><\/pre>\nCodes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong>?<\/strong><\/p>\n\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\nExample of HTML legend tag<\/title>\n<\/head>\n\n\n\nNinja 300<\/option>\nNinja 450<\/option>\n<\/optgroup>\n\nPulsar 200<\/option>\nPulsar 150<\/option>\n<\/optgroup>\n<\/select>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Output:<\/strong><\/p>\n\n\n<\/p>\n9. “” element<\/h4>\nThis element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.<\/p>\nSyntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Syntax:<\/strong><\/p>\n ... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
... <\/option><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n\n\n Bikes <\/option>\n Cars <\/option>\n Buses <\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\nExample of HTML option tag<\/title>\n<\/head>\n\n
Output:<\/strong><\/p>\n<\/p>\n10. “” element<\/h4>\nThis element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\nSyntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is basically used to show the output of a calculation (e.g. in a scripted calculation).<\/p>\n
Syntax:<\/strong><\/p>\n ... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
... <\/output><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n\n +\n =\n<\/output>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\nExample of HTML output Tag<\/title>\n<\/head>\n\n
Output:<\/strong><\/p>\n<\/p>\n11. “” element<\/h4>\nThis element is used to make a selection from a list within a form.<\/p>\nSyntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is used to make a selection from a list within a form.<\/p>\n
Syntax:<\/strong><\/p>\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n\n\nBike<\/option>\nCar<\/option>\nBus<\/option>\n<\/select>\n<\/form>\n<\/body>\n<\/html><\/pre>\nOutput:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\nExample of HTML select Tag<\/title>\n<\/head>\n\n
Output:<\/strong><\/p>\n<\/p>\n12. “” element<\/h4>\nThis element is used to define multi-line text inputs (e.g. for address).<\/p>\nSyntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
This element is used to define multi-line text inputs (e.g. for address).<\/p>\n
Syntax:<\/strong><\/p>\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Put your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form><\/pre>\nCodes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Codes:<\/strong><\/p>\n\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n\nPut your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
\n\n\nExample of HTML textarea Tag<\/title>\n<\/head>\n\n
Put your Comment:\nPut here...<\/textarea>\n<\/p>\n<\/form>\n<\/body>\n<\/html> <\/pre>\nOutput:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
Output:<\/strong><\/p>\n<\/p>\nConclusion<\/h3>\nThere are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"} Community Articles Topics Q&A Learn Course Programming Dictionary Tools Library Development tools Website Source Code PHP Libraries JS special effects Website Materials Extension plug-ins AI Tools Leisure Game Download Game Tutorials English 簡(jiǎn)體中文 English 繁體中文 日本語(yǔ) ??? Melayu Fran?ais Deutsch Login singup Table of Contents Syntax and Example 1. “<form>” element 2. “<input>” element 3. “<datalist>” element 4. “<fieldset>” element 5. “<keygen>” element 6. “<label>” element 7. “<legend>” element 8. “<optgroup>” element 9. “<option>” element 10. “<output>” element 11. “<select>” element 12. “<textarea>” element Conclusion Home Web Front-end HTML Tutorial HTML Form Elements HTML Form Elements PHPz Sep 04, 2024 pm 04:14 PM html html5 HTML Tutorial HTML Properties HTML tags In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “” tag, and these elements, along with other standard and unique attributes, give a form and structure as well, which let the users know what to do with the form and how to proceed in a structural manner. Explain HTML Form Elements?(including syntax and examples with output) Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. SL No. Tags Meanings / Descriptions ? 1 To define a HTML form for user inputs ? 2 To define input control ? 3 To specify a list of pre-defined options ? 4 To define group related elements ? 5 To define a secure input ? 6 To define a label of input ? 7 To define a caption for fieldset ? 8 ? To define a group of similar options. ? ? 9 ? ? To define an option for the drop-down. ? 10 ? ? To define a? result ? 11 ? ? To define a list of the drop-down. ? 12 ? ? To define a multiline input area. Note: Most of the HTML tag elements discussed here are for HTML5, the latest HTML language version. The tag element is no longer supported in HTML5; it was actually used for the prior version of HTML. Syntax and Example Some syntaxes and examples of HTML Form Elements with outputs are discussed below: 1. “” element This element can contain many other elements as well including the below: Example for a “” element with input and submit button: Syntax: <form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html> Output: 2. “” element ?This element is an inline element and belongs to the form-element group. Syntax: <form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> Codes: <!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html> Output: ? ? ? ? 3. “” element It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list. Syntax: <input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> Codes: <! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html> Output: 4. “” element This element is basically used to group related elements in forms and draws a box around similar elements. Syntax: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Codes: <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 5. “” element This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML. Syntax: <keygen form="form_id"> Codes: <!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html> Output: 6. “” element This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users. Syntax: <label for="control id" > ... </label> Codes: <!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html> Output: 7. “” element This element actually defines a caption for a element. It’s kind of a supporting element for another element, a part of the group element. Syntax: <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> Codes: Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form> Output: 8. “” element This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily. Syntax: <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Codes:? Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select> Output: 9. “” element This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option. Syntax: <option value="option-value"> ... </option> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html> Output: 10. “” element This element is basically used to show the output of a calculation (e.g. in a scripted calculation). Syntax: <output> ... </output> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html> Output: 11. “” element This element is used to make a selection from a list within a form. Syntax: <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Codes: Example of HTML select Tag <select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select> Output: 12. “” element This element is used to define multi-line text inputs (e.g. for address). Syntax: <form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form> Codes: <!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html> Output: Conclusion There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.The above is the detailed content of HTML Form Elements. 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 Undress AI Tool Undress images for free Undresser.AI Undress AI-powered app for creating realistic nude photos AI Clothes Remover Online AI tool for removing clothes from photos. Clothoff.io AI clothes remover Video Face Swap Swap faces in any video effortlessly with our completely free AI face swap tool! Show More Hot Article Guide: Stellar Blade Save File Location/Save File Lost/Not Saving 4 weeks ago By DDD Agnes Tachyon Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Oguri Cap Build Guide | A Pretty Derby Musume 2 weeks ago By Jack chen Dune: Awakening - Advanced Planetologist Quest Walkthrough 4 weeks ago By Jack chen Date Everything: Dirk And Harper Relationship Guide 4 weeks ago By Jack chen Show More Hot Tools Notepad++7.3.1 Easy-to-use and free code editor SublimeText3 Chinese version Chinese version, very easy to use Zend Studio 13.0.1 Powerful PHP integrated development environment Dreamweaver CS6 Visual web development tools SublimeText3 Mac version God-level code editing software (SublimeText3) Show More Hot Topics Where is the login entrance for gmail email? 8638 17 Java Tutorial 1783 16 CakePHP Tutorial 1728 56 Laravel Tutorial 1579 28 PHP Tutorial 1444 31 Show More Related knowledge What are the essential HTML elements for structuring a webpage? Jul 03, 2025 am 02:34 AM The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part. Implementing client-side form validation using HTML attributes. Jul 03, 2025 am 02:31 AM Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen How to group options within a select dropdown using html? Jul 04, 2025 am 03:16 AM Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams. Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this Submitting Form Data Using New HTML5 Methods (FormData) Jul 08, 2025 am 02:28 AM It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled. See all articles
There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.<\/p>"}
In Web Development Technologies (especially for the front-end), “HTML” is the basic or primary markup language that we use to display the web pages (the page which we see on a website). Sometimes, in an HTML page, along with the other content display, we need to take some user inputs as well (especially in dynamic web sites). And to take the user inputs in an HTML page, we need to use multiple form elements to create those forms properly, and with the help of those forms, we correctly take the user inputs and put those inputs (data) in our internal Databases at the back-end. Now, as we know that HTML codes are written under various tag elements (<>), so, basically, “HTML Form Elements” are those elements that are used inside a “
Since there are multiple HTML form elements to create a form & give the form a proper look in a structured way, below are some of them explained one by one.
1
2
3
4
5
6
7
8
To define a group of similar options.
?
9
To define an option for the drop-down.
10
To define a? result
11
To define a list of the drop-down.
12
To define a multiline input area.
Some syntaxes and examples of HTML Form Elements with outputs are discussed below:
This element can contain many other elements as well including the below:
Example for a “
Syntax:
<form action="/test_page.php" method="get"> Your Name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form>
Codes:
<!DOCTYPE html> <html> <body> <form action="/test_page.php"> Your name: <input type="text" name="Name" value="Raju"><br> <input type="submit" value="Submit"> </form> </body> </html>
Output:
?This element is an inline element and belongs to the form-element group.
<form action="/test_page.php"> Input name: <input type="text" name="name"><br> Input age: <input type="text" name="age"><br> <input type="submit" value="Submit"> </form>
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> Input name: <input type="text" name="name" value=""><br> Input age: <input type="text" name="age" value=""><br> <input type="submit" value="Submit"> </form> </body> </html>
? ? ? ?
It usually specifies a pre-defined list of inputs for element where users can choose any option from the pre-defined list.
<input list="fruits"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist>
<! DOCTYPE html> <html> <body> <form action="/test_page.php" method="get"> <input list="fruits" name="fruit"> <datalist id="fruits"> <option value="Mango"> <option value="Apple"> <option value="Banana"> <option value="Pomegranate"> <option value="Pineapple"> </datalist> <input type="submit"> </form> </body> </html>
This element is basically used to group related elements in forms and draws a box around similar elements.
<form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form>
This element may be located outside the form, but it might still be a part of the form. Usually, this element is used to specify one or more forms. This element is newly used in the HTML5 version to generate an encryption key to pass encrypted data over a form in a website based on HTML.
<keygen form="form_id">
<!DOCTYPE html> <html> <body> <form action="/test_page.php" method="get" id="secureform"> Username: <input type="text" name="user_name"> <input type="submit"> </form> <p>The below mentioned keygen field is outside of the form, but it's still a part of the above form.</p> Encryption: <keygen name="security" form="secureform"> </body> </html>
This element basically gives a name for the input form to make the users understand what input data it should be. It acts as an indicator for users.
<label for="control id" > ... </label>
<!DOCTYPE html> <head> <title>Example of HTML label tag</title> </head> <body> <form> <input type="radio" name="gender" value="boy" id="boy"> <label for="boy">Boy</label> <input type="radio" name="gender" value="girl" id="girl"> <label for="girl">Girl</label> </form> </body> </html>
<fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset>
Example of HTML legend tag <form> <fieldset> <legend>Celebrity:</legend> Name: <input type="text"><br> Phone: <input type="number"><br> Age: <input type="text"> </fieldset> </form>
This element is a group-related element used for options in a drop-down list in an HTML form. It helps the users to handle a long list easily.
<select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select>
Codes:?
Example of HTML legend tag <select> <optgroup label="Kawasaki Bikes"> <option value="ninja300">Ninja 300</option> <option value="ninja450">Ninja 450</option> </optgroup> <optgroup label="Bajaj Bikes"> <option value="pulsar200">Pulsar 200</option> <option value="pulsar150">Pulsar 150</option> </optgroup> </select>
This element is used to represent an option from a dropdown list under element; the dropdown list must contain at least one option.
<option value="option-value"> ... </option>
<!DOCTYPE html> <html> <head> <title>Example of HTML option tag</title> </head> <body> <form> <select> <option value="Bikes"> Bikes </option> <option value="Cars"> Cars </option> <option value="Buses"> Buses </option> </select> </form> </body> </html>
This element is basically used to show the output of a calculation (e.g. in a scripted calculation).
<output> ... </output>
<!DOCTYPE html> <html> <head> <title>Example of HTML output Tag</title> </head> <body> <form oninput="result.value=parseInt(x.value)+parseInt(y.value)"> <input type="range" id="x" value="50"> + <input type="number" id="y" value="100"> = <output name="result" for="x y"></output> </form> </body> </html>
This element is used to make a selection from a list within a form.
<select> <option value="Bike">Bike</option> <option value="Car">Car</option> <option value="Bus">Bus</option> </select>
Example of HTML select Tag
This element is used to define multi-line text inputs (e.g. for address).
<form> <p>Put your Comment: <textarea cols="50" rows="6">Put here...</textarea> </p> </form>
<!DOCTYPE html> <html> <head> <title>Example of HTML textarea Tag</title> </head> <body> <form> <p>Put your Comment: <textarea cols="30" rows="4">Put here...</textarea> </p> </form> </body> </html>
There are so many HTML form elements available; in this article, we have discussed some of the basic or native form elements. It helps us to create proper and functional HTML forms. The point to be noted is that most of the HTML form elements need a few attributes to be included along with them. Some of the elements depend on each other, which must be coded together. All the browsers may not display the elements which are already deprecated.
The above is the detailed content of HTML Form Elements. For more information, please follow other related articles on the PHP Chinese website!
Undress images for free
AI-powered app for creating realistic nude photos
Online AI tool for removing clothes from photos.
AI clothes remover
Swap faces in any video effortlessly with our completely free AI face swap tool!
Easy-to-use and free code editor
Chinese version, very easy to use
Powerful PHP integrated development environment
Visual web development tools
God-level code editing software (SublimeText3)
The web page structure needs to be supported by core HTML elements. 1. The overall structure of the page is composed of , , which is the root element, which stores meta information and displays the content; 2. The content organization relies on title (-), paragraph () and block tags (such as ,) to improve organizational structure and SEO; 3. Navigation is implemented through and implemented, commonly used organizations are linked and supplemented with aria-current attribute to enhance accessibility; 4. Form interaction involves , , and , to ensure the complete user input and submission functions. Proper use of these elements can improve page clarity, maintenance and search engine optimization.
When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience.
Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part.
Client-sideformvalidationcanbedonewithoutJavaScriptbyusingHTMLattributes.1)Userequiredtoenforcemandatoryfields.2)ValidateemailsandURLswithtypeattributeslikeemailorurl,orusepatternwithregexforcustomformats.3)Limitvaluesusingmin,max,minlength,andmaxlen
Use tags in HTML to group options in the drop-down menu. The specific method is to wrap a group of elements and define the group name through the label attribute, such as: 1. Contains options such as apples, bananas, oranges, etc.; 2. Contains options such as carrots, broccoli, etc.; 3. Each is an independent group, and the options within the group are automatically indented. Notes include: ① No nesting is supported; ② The entire group can be disabled through the disabled attribute; ③ The style is restricted and needs to be beautified in combination with CSS or third-party libraries; plug-ins such as Select2 can be used to enhance functions.
HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams.
To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this
It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled.