#22136 closed Cleanup/optimization (fixed)

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

Reported by: FlipperPA Owned by: FlipperPA
Component: Forms Version: 1.6
Severity: Normal Keywords: textarea, rows, cols
Cc: FlipperPA 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 Changed 14 months ago by FlipperPA

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 in reply to: ↑ description ; follow-up: Changed 14 months ago by 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 :)

comment:3 in reply to: ↑ 2 Changed 14 months ago by FlipperPA

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 Changed 14 months ago by FlipperPA

  • Status changed from new to assigned

comment:5 Changed 14 months ago by FlipperPA

  • Cc FlipperPA added

comment:6 Changed 14 months ago by claudep

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

comment:7 Changed 14 months ago by afuna

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 Changed 14 months ago by aaugustin

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 Changed 14 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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