CoderTools Web site

HTML TextArea

Entering Multiple Lines of Text


If you want a multi line text entry control to save descriptions and paragraphs of text to a server you can the use the textarea tag.

Examples for <textarea>


Here is a simple example. Three things to note, 1 the cols attribute is required and specified the width in columns of the textarea. And 2, the control acts like a pre tag in that any whitespace is included in the output - in this example the word Default is tabbed to the right and appears so in the textarea; in normal HTML the tab would not show. And 3, you can change the text in the textarea.
    <textarea name="description" cols="50">
        Default content in the textarea control
    </textarea>Give it a go!


Just as you can specify the width in columns you can also specify the height in rows:
    <textarea name="description" cols="50" rows="10">
        Default content in the textarea control
    </textarea>Give it a go!


With this example we set the disabled attribute. This is to stop users changing the contents of the textarea. Note that the contents is still selectable and so can be copied to the clipboard (i.e. highlight the text, right click and press copy).
    <textarea name="description" cols="50" disabled>
        Default content in the textarea control
    </textarea>Give it a go!
With this example we set the readonlyattribute. This is the same as disabled except the control will not be greyed out.
    <textarea name="description" cols="50" readonly>
        Default content in the textarea control
    </textarea>Give it a go!

The server side script used in the above examples for give it a go is this:
        <?php
            
            echo $_POST['description'];
            
        ?>
    

Attributes for <textarea>


Name Values Description
cols a number Specify the width in character columns.
Rows a number Specify the height in number of lines.
name text Name of the control that is used by server side script to identify the control to retrieve its contents.
disabled disabled Disable the control. On most browsers this will grey out the content User can still select and copy content.
readyonly readyonly Disable the control. User can still select and copy content.

8/19/2017 5:51:25 PM
Terms Of Use | Privacy Statement | Copyright 2006-2015 © Independence Software LLP