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?

Jan 28, 2021 pm 05:30 PM
html textarea

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>
Copy after login

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"
Copy after login

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>
Copy after login

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>
Copy after login

Insert the above code between and on the page. Calling method:

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

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>
Copy after login

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 of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles