How do I make #cols work in textarea? According to the Form API, you control the number of columns in a textarea with the #cols attribute. However, setting this seems to have no effect when I use it inside a $form array (the companion #rows attribute works as expected).

This is question is already on stack overflow however the answer utilizes css instead of the cols attribute which seems like a cheat.

    $form['message'] = array(
        '#type' =&gt; 'textarea',
        '#title' =&gt; t('Message'),
        '#resizable' =&gt; FALSE,
        '#cols' =&gt; 20, 
        '#rows' =&gt; 10,
    );
Drupal will add the cols attribute to the textarea, however its CSS which controls it. i.e Width of the textarea or its container is controlling it.

Here is the fiddle example explaining this scenario 

In the above example first textarea didn't affected by any CSS so it has 100 cols, however the second one is bounded with another container and its width is restricted, so textarea is rendered within the available width that's why cols value didnt affected the textarea.

The same is applicable for rows attribute when you set height attribute.