Home >Web Front-end >HTML Tutorial >What are the attributes of the textarea tag in HTML?

What are the attributes of the textarea tag in HTML?

coldplay.xixi
coldplay.xixiOriginal
2021-01-28 17:30:4625038browse

The attributes of the textarea tag in HTML are: 1. cols is a vertical column; 2. name, the name of the text box; 3. warp, when [warp="off"] means that the text area is not automatically Line wrap; 4. rows horizontal columns; 5. class is generally used to call settings in external css.

The operating environment of this article: Acer S40-51, HBuilderX.3.0.5&&HTML5 version, Windows10 Home Chinese version

Related learning recommendations: html video tutorial

The attributes of the textarea tag in HTML are:

1, cols, vertical column. Without setting the style sheet, it represents the number of bytes that can fit in one line. For example, cols=60 means that a line can hold up to 60 bytes, which is 30 Chinese characters. Another thing to note is that the width of the text box is adjusted through this. Enter the value of cols, and then define the size of the input text font (if not defined, the default value will be used), then the width of the text box will be determined.

2, rows, horizontal columns. Indicates the number of rows that can be displayed. For example, rows=10 means that 10 rows can be displayed. If there are more than 10 lines, you need to drag the scroll bar to browse. (Same as above, the height of the text box is controlled through this.)

3, name, the name of the text box, this is essential because it must be used when storing text .

4, warp, when warp="off" means that the text area will not wrap automatically. Of course, if it is not written, it will wrap automatically by default. This parameter is generally used less frequently.

5, style, this is a very practical parameter, which can be used to set the background color of the text box, the color and form of the scroll bar, the border color, the size and color of the input font, etc.

6, class, are generally used to call settings in external css.

Example 1: Set the number of rows of the text box to 40 and the number of columns to 10. The name is text. Expression form

<textarea cols=40 rows=10 name=text></textarea>

Example 2: Cancel the scroll bar on the right side of the text box. The expression

<textarea cols=40 rows=10 name=text style="overflow:auto"></textarea>。style="overflow:auto"

means that the scroll bar will be automatically displayed when the input text exceeds the set number of lines.

Example 3: Set the background color of the text box.

<textarea cols=40 rows=10 name=text style="background-color:BFCEDC"></textarea>

Example 4: In addition, setting the scroll bar color, border color, font size, color, line spacing, etc. of the text box can be set directly in style. However, these are generally set in CSS and can be called directly.

The following is a piece of CSS setting code: it should be easier to understand. What is set in the textbox is the background color of the text box, the color and thickness of the upper, lower, left and right borders, and the size of the input font, etc.

<style>
.textbox { BACKGROUND: #BFCEDC; BORDER-TOP: #7F9DB9 1px solid; BORDER-LEFT: #7F9DB9 1px solid; BORDER-RIGHT: #7F9DB9 1px solid; BORDER-BOTTOM: #7F9DB9 1px solid; FONT-FAMILY: "宋体", "Verdana", "Arial", "Helvetica"; FONT-SIZE: 12px; TEXT-ALIGN: LIFT;}
</style>

Insert the above code between 93f0f5c25f18dab9d176bd4f6de5d30e and 9c3bca370b5104690d9ef395f2c5f8d1 on the page. Calling method:

<textarea cols=40 rows=10 name=text class="textbox"></textarea>

The name in class="" corresponds to the name of the setting to be used in css. Once you are familiar with these parameters, it will be very convenient to modify and beautify the text input box.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php中文网</title>
<script>
function displayResult()
{
    alert(document.getElementById("myTextarea").value);
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在php中文网,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, 和 PHP 等各种前端内容。
</textarea>
<br>
<button type="button" onclick="displayResult()">弹出 textarea 元素的文本</button>
</body>
</html>

If you want to know more about programming learning, please pay attention to the php training column!

The above is the detailed content of What are the attributes of the textarea tag in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn