I tried making a form element with the following properties:

   '#type' => 'textfield',
   '#maxlength' => 2,
   '#size' => 2,

When the field is displayed, the size properties doesn't seem to take effect. It turns out that the following block from drupal.css conflicts:

.node-form .form-text {
  display: block;
  width: 95%;
}

The width property takes precedence over the size property. Using width:auto; allows the size property to have an effect. That works fine with an extra CSS file, but that's probably not an appropriate change for drupal.css.

Comments

chx’s picture

Status: Active » Closed (won't fix)

Override in your theme by width: auto.