Introduction
TextBox is essential
interface control for any application to get text input by user. Here we will
create TextBox in HTML 5. We create TextBox by <input> tag with type="type_name"
attribute. Like as given below:
We take two TextBox by writing below code:
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="post">
- First Name
- <input type="text" name="fname"/>
- Last Name
- <input type="text" name="lname"/>
- </form>
- </body>
- </html>
Here fname and lname is a unique name for these control. When we run this code, The output will look like as below:
We also can define width of TextBox by size attributes as
- <input type="text" name="fname" size="25"/>
Now we run this code. The output will look like
as below
We can also make TextBox to accept password by
type="password" attribute value. Like below code
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="post">
- First Name
- <input type="text" name="fname" size="25"/>
- Last Name
- <input type="text" name="lname" size="25"/>
- <br />
- Password
- <input type="password" name="pword" size="25" />
- </form>
- </body>
- </html>
We run this code. The output will look like as
below: