Text box

Updated: 02/04/2024 by Computer Hope
Text box

Alternatively called a text field, a text box is a page section or object allowing users to enter text. Text boxes are used on the Internet for pages requiring user input. You may also see a text box in a word processing program when creating a form that requires a user to enter information.

Examples of text boxes

There are two main types of text boxes you are likely to encounter.

One-line text box

Below is an example of a one-line text box used for a name, e-mail, or password. The text box may have a fixed length, allowing only a few words to be entered. It may also allow more text than the length of the text box, requiring a user to use arrow keys to scroll horizontally to see all entered text.

Multiple-line textarea box


Below is an example of a multiple-line textarea text box for entering a lot of data and is often used for typing a message. Text entered in a multiple-line text box automatically wraps to the next line when it reaches the right edge of the text box.

Creating an HTML text box

Below is the HTML (hypertext markup language) source code that creates the above boxes using the HTML form tag, input tag, and textarea tag. The input tag with the name attribute is a single one-line text box, and the textarea tag is a multiple-line text box. The "script name" in the action attribute should be changed to the name and location of your script file. For example, it could be changed to an ASP (Active Server Pages), Perl, PHP (PHP: Hypertext Preprocessor), or Python script file.

<form action="script name" method="get">
Name: <input type="text" name="name"><br>
Message: <textarea rows="2" cols="20"></textarea><br>
<input type="submit" value="Submit">
</form>

How to copy text from a text box

To copy text box text, select the text in the text box and either use the keyboard shortcut to copy or right-click and choose copy from the context menu. Below are two text boxes to practice copying text from the first text box into the second text box.

Select all of the text or only the text you want to copy. Once the text has been selected, press the Ctrl+C keyboard shortcut to copy the text.

Tip

If there is a lot of text in a text box, click anywhere in the text box and press Ctrl+A to select all text.

After copying the text, click in the above text box and use the keyboard shortcut Ctrl+V to paste the text.

Tip

To move text, instead of copying text, instead of using Ctrl+C, use Ctrl+X to cut the text.

Field, Omnibox, Spin box, Text, Textarea, Web design terms, Word processing, Word processor