The Html <text> tag is used to define the single-line text field on a web page. When we set the value text to the type attribute of an input element as shown in the following syntax:
Syntax:
<input type="text" name="firstname"/>
Example
<html>
<head>
<title> Example of text field </title>
</head>
<body>
<form>
<br>
<label>
Firstname:
</label>
<input type="text" name="FN" size="5"/>
<br>
<br>
<label>
Lastname:
</label>
<input type="text" name="LN" size="10"/>
<br>
<br>
<label>
Course:
</label>
<input type="text" name="Course" size="15"/>
<br>
<br>
<label>
College:
</label>
<input type="text" name="Course" size="20"/>
</form>
</body>
</html>
Output:
Attributes of HTML Text Tag
1. Size
The size attribute is used to define the length of the text field. This attribute accepts the numeric values greater than zero. If you not specify this attribute, by default its value is 20. The following syntax determines how to use this attribute:
2. Value
The value attribute is used to define the value, which is displayed in the text field. The following syntax determines how to use this attribute:
<input type="text" name="firstname" value=?Any_value? />
3. maxlength
The maxlength attribute is used to define a value. This value identifies the maximum number of characters accept by the input. The following syntax determines how to use this attribute:
<input type="text" name="firstname" maxlength="5" />
4. minlength
The maxlength attribute is used to define a value. This value identifies the minimum number of characters accept by the input. The following syntax determines how to use this attribute:
<input type="text" name="firstname" minlength="5" />
Leave a Reply