Text Input Control in HTML Form

<input type="text"> defines a one-line input field for text input. It is used for items that require only one line of user input, such as search boxes or names. Example :
<!DOCTYPE html>
<html>
   <head>
	  <title>Text Input Control</title>
   </head>
   <body>
     <form action="login_page.php" method="post">
	First name :
	<input type="text" name="username" maxlength="30"/>
	<br />
	Last Name :
	<input type="text" name="lastname" maxlength="30"/>
     </form>
</body>
</html>
The output of above code will be :


Attributes :

The attributes used in the text input control  are as follows :

  • type : Indicates the type of input control and for text input control it will be set to text.
  • name : Used to give a name to the control which is sent to the server to be recognized and get the value.
  • value : This can be used to provide an initial value inside the control.
  • size : Used to specify the width of the text-input control in terms of characters.
  • maxlength : Used to specify the maximum number of characters a user can enter into the text box.



Next Topic :