Opened 10 years ago

Closed 10 years ago

#22136 closed Cleanup/optimization (fixed)

Textarea Widget Outputs Default cols & rows, overriding styles provided by CSS

Reported by: Timothy Allen Owned by: Timothy Allen
Component: Forms Version: 1.6
Severity: Normal Keywords: textarea, rows, cols
Cc: Timothy Allen Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The default Textarea class in widgets.py has default attributes passed along to the HTML:

default_attrs = {'cols': '40', 'rows': '10'}

Since CSS is used for most styling across the web today, this seems like a step backwards. Is there any reason not to remove these defaults?

Change History (9)

comment:1 by Timothy Allen, 10 years ago

In regards to the comment in the source:

# The 'rows' and 'cols' attributes are required for HTML correctness.

The rows and cols attributes in HTML are not required; in fact, if omitted, HTML defaults to 2 rows and 20 cols. Reference:

http://www.w3schools.com/tags/att_textarea_cols.asp
http://www.w3schools.com/tags/att_textarea_rows.asp

in reply to:  description ; comment:2 by Aymeric Augustin, 10 years ago

Replying to FlipperPA:

Is there any reason not to remove these defaults?

At least backwards-compatibility. Now you can argue about whether it's a good reason :)

in reply to:  2 comment:3 by Timothy Allen, 10 years ago

Replying to aaugustin:

Replying to FlipperPA:

Is there any reason not to remove these defaults?

At least backwards-compatibility. Now you can argue about whether it's a good reason :)

Textareas will still appear in any browser I know of regardless of providing rows and cols due to the HTML defaults. But point taken! :)

comment:4 by Timothy Allen, 10 years ago

Status: newassigned

comment:5 by Timothy Allen, 10 years ago

Cc: Timothy Allen added

comment:6 by Claude Paroz, 10 years ago

Hasn't the CSS precedence over cols and rows attributes? If yes, then I don't see the point in removing them.

comment:7 by afuna, 10 years ago

CSS will take precedence over the HTML attributes, so the textarea size should be pretty easy to override.

(In addition the django defaults seem like a good idea, because the HTML defaults result in a *tiny* barely-usable textarea).

comment:8 by Aymeric Augustin, 10 years ago

Then all we need is to change the comment to something like "use slightly better defaults than HTML's 20x2 box".

I would support even more reasonable defaults, like 72x6, but that could break layouts relying on the current default size.

comment:9 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 9f76d0d351953b513e9cd4e2fbd7690077a65fae:

Fixed #22136 -- Updated comment for Textarea widget

Thanks Aymeric Augustin for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top