Definition: The tag is used to collect user information. Input represents an input object in the Form form.
According to different type attribute values, input fields have many forms. Input fields can be text fields, checkboxes (single/checkboxes), masked text controls, radio buttons, (submit/reset) buttons, etc.
Example:
<form action="form_action.asp" method="get"> <p>First name: <input type="text" name="fname" /></p> <p>Last name: <input type="text" name="lname" /></p> <input type="submit" value="Submit" /></form>
Syntax: ;
Attribute value:
value | 描述 |
button | 定义可点击按钮(多数情况下,用于通过 JavaScript 启动脚本)。 |
checkbox | 定义复选框。 |
file | 定义输入字段和 "浏览"按钮,供文件上传 |
hidden | 定义隐藏的输入字段。 |
image | 定义图像形式的提交按钮。 |
password | 定义密码字段。该字段中的字符被掩码。 |
radio | 定义单选按钮。 |
reset | 定义重置按钮。重置按钮会清除表单中的所有数据。 |
submit | 定义提交按钮。提交按钮会把表单数据发送到服务器。 |
text | 定义单行的输入字段,用户可在其中输入文本。默认宽度为 20 个字符。 |
具体介绍如下
定义可点击的按钮(标准的windows风格的按钮),但没有任何行为。button 类型常用于在用户点击按钮时启动 JavaScript 程序。因此,要让按钮跳转到某个页面上还需要加入写JavaScript代码。
<form name="FormButton"> <input type="button" name="随便填" value="点击按钮" onclick="window.open('http://www.cnblogs.com/Loonger/')"> </form>
效果:
定义复选框。复选框允许用户在一定数目的选择中选取一个或多个选项。多选框,常见于注册时选择爱好、性格、等信息。参数有name,value及特别参数checked(表示默认选择)其实最重要的还是value值,提交到处理页的也就是value。(附:name值可以不一样,但不推荐。)
<form name="FormCheckbox"> <input type="checkbox" name="animal" value="dog" checked>This is a dog<br /> <input type="checkbox" name="animal" value="cat">This is a cat<br /> <input type="checkbox" name="animal" value="horse">This is a horse<br /> </form> /*name值可以不一样,但不推荐*/<form name="FormCheckbox"> <input type="checkbox" name="animal" value="dog" checked>This is a dog<br /> <input type="checkbox" name="animal" value="cat">This is a cat<br /> <input type="checkbox" name="animal" value="horse">This is a horse<br /> </form>
效果:
用于文件上传。该控件带有一个文本框和一个浏览按钮.当你在BBS、EMAIL中上传附件时一定少不了的控件。
<form> <input type="file" name="pic" accept="image/gif" /></form>
效果:
定义隐藏字段。隐藏字段对于用户是不可见的(如果一个非常重要的信息需要被提交到下一页,但又不能或者无法明示。 一句话,你在页面中是看不到hidden在哪里。最有用的是hidden的值。)隐藏字段通常会存储一个默认值,它们的值也可以由 JavaScript 进行修改。
<form name="FormHidden"> your hidden info here: <input type="hidden" name="hiddeninfo" value="Loong's Blog"> </form> <script> alert("隐藏域的值是 "+document.FormHidden.hiddeninfo.value) </script>
效果:
定义图像形式的提交按钮。
<form> <input type="image" src="submit.gif" alt="Submit" /></form>
定义密码字段。密码字段中的字符会被掩码(显示为星号或原点)。
<form> Email:<input type="text" name="email" /><br /> Password: <input type="password" name="pwd" maxlength="8" /><br /></form>
效果:
定义单选按钮,出现在多选一的页面设定中。参数同样有name,value及特别参数checked. 不同于checkbox的是,name值一定要相同,否则就不能多选一。当然提交到处理页的也还是value值。
<form action="/example/html/form_action.asp" method="get"> <input type="radio" name="sex" value="male" /> Male<br /> <input type="radio" name="sex" value="female" /> Female<br /></form>/*下面是name值不同的一个例子,就不能实现多选一的效果了*/ <form> <input type="radio" name="checkit1" value="a" checked><br> <input type="radio" name="checkit2" value="b"><br> <input type="radio" name="checkit3" value="c"><br> </form>
效果:
;
定义“提交”和“重置”两按钮,提交按钮用于向服务器发送表单数据。数据会发送到表单的 action 属性中指定的页面。重置按钮则起个快速清空所有填写内容的功能。
<form> Email: <input type="text" name="email" /><br /> Password: <input type="text" name="pin" maxlength="4" /><br /> <input type="reset" value="Reset" /> <input type="submit" value="Submit" /></form>
效果:
输入类型是text,这是我们见的最多也是使用最多的,比如登陆输入用户名,注册输入电话号码,电子邮件,家庭住址等等。当然这也是Input的默认类型。
参数name:同样是表示的该文本输入框名称。
参数size:输入框的长度大小。
参数maxlength:输入框中允许输入字符的最大数。
参数value:输入框中的默认值
特殊参数readonly:表示该框中只能显示,不能添加修改
<form action="/example/html/form_action.asp" method="get"> <p>Email: <input type="text" name="email" /></p> <p>Password: <input type="text" name="pin" maxlength="18" /></p> </form>
效果:见password部分。

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools