Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textarea's rows, and cols attribute in CSS

Tags:

css

styling

People also ask

What is rows and cols in textarea?

Rows and Cols are the number of characters that are going to fit in the textarea rather than pixels or some other potentially arbitrary value. Go with the rows/cols.

What is the use of cols attribute in textarea tag?

The HTML <textarea> cols Attribute is used to tell the browser how many average-width characters should fit on a single line i.e the number of columns to display. It is used to specify the visible width of the <Textarea> Element.

What is cols attribute in HTML?

The cols attribute specifies the visible width of a text area. Tip: The size of a textarea can also be set by the CSS height and width properties.


<textarea rows="4" cols="50"></textarea>

It is equivalent to:

textarea {
    height: 4em;
    width: 50em;
}

where 1em is equivalent to the current font size, thus make the text area 50 chars wide. see here.


width and height are used when going the css route.

<!DOCTYPE html>
<html>
    <head>
        <title>Setting Width and Height on Textareas</title>
        <style>
            .comments { width: 300px; height: 75px }
        </style>
    </head>
    <body>
        <textarea class="comments"></textarea>
    </body>
</html>

I don't think you can. I always go with height and width.

textarea{
width:400px;
height:100px;
}

the nice thing about doing it the CSS way is that you can completely style it up. Now you can add things like:

textarea{
width:400px;
height:100px;
border:1px solid #000000;
background-color:#CCCCCC;
}

As far as I know, you can't.

Besides, that isnt what CSS is for anyway. CSS is for styling and HTML is for markup.