size Attribute


 

Where to use the size Attribute


Description

For the input type="text", input type="password" and input type="file" elements, the size attribute may be used to specify the width of the text box, measured in average character widths. This does not affect how many characters may be entered - use the maxlength attribute for that (but not for input type="file").

For the select element, the size attribute may be used to specify the number of option items which should be visible at any one time. This is only applicable if the select element is rendered as a scrolled list; if the list is displayed in a different manner (e.g. a drop-down list) it is not relevant. In some cases, however, the rendering method is changed if the size attribute is specified. For example, this is how my newly-downloaded version of Firefox 3 displays select lists:

  • If neither multiple nor size attributes are specified:
    select is rendered as a drop-down list
  • If multiple is specified but not size:
    select is rendered as a scrolled list, with 20 items visible at any one time
  • If size is specified but not multiple:
    select is rendered as a scrolled list, with the number of items visible at any one time being the value of the size attribute.
  • If both size and multiple attributes are specified:
    select is rendered as a scrolled list, with the number of items visible at any one time being the value of the size attribute.

This behaviour will vary between user agents, however.


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Attribute Index (XHTML 1.1) > size Attribute (XHTML 1.1)