[whatwg] Allowing size and maxlength attributes for all new input types would provide better fallbacks

Jukka K. Korpela jkorpela at cs.tut.fi
Tue Feb 15 23:31:53 PST 2011

The current version disallows the size and maxlength attributes in input
elements when  type="time", type="date", type="datetime",
type="datetime-local", type="number", type="range", or type="color" is used.
I suppose the reason is that for other new input types, browsers are
expected to use advanced user interface, either with no visible text field
or with a text field of a size determined by the browser.

However, the method of extending forms with new input types is based on the
clever idea that using a new attribute in input elements, non-supporting
browsers will imply type="text" and use a normal text input field as
fallback. This idea gets somewhat broken if size and maxlength attributes
cannot be used. Setting the visible width and imposing a maximum length of
input in characters are often useful hints. E.g., for <input type="time">,
it would be useful to have size="5" maxlength="5" (perhaps combined with a
CSS setting that sets the font to monospace for consistency) to convey or
support a message about expected input format as well as to prevent some
input errors.

There considerations also apply to HTML5-supporting browsers if they
implement the new input types using text boxes. For example, input
type="color" could be implemented that way, with the required checks on the
user input but with no color picker.

Using CSS for the width is less satisfactory, since there is no "(average)
width of characters" concept in CSS, and there is no CSS counterpart to
maxlength, which is a functional rather than presentational attribute.

For the input types mentioned, the meanings of size and and maxlength could
be formulated so that user agents shall treat the size attribute as a
suggested visible width of a text box used for the value as text, if such a
presentation is used, and the maxlength attribute should be ignored, as it
is only meant for nonconforming browsers that treat the element as having

Yucca, http://www.cs.tut.fi/~jkorpela/
Yucca, http://www.cs.tut.fi/~jkorpela/ 

More information about the whatwg mailing list