Form Widget Attributes


The autofocus attribute is used for specifying a default form widget where the insertion pointer will be placed once the page loads. There can only be one element with the autofocus attribute.


The disabled attribute is an empty attribute used for disabling the user from entering input into a widget. It is typically used in combination with JavaScript. This attribute is inheritable, which means if a container element( for example fieldset) is set with this attribute then all the widgets within this container will be disabled.


This attribute is most commonly used in the input element. The element is made read-only i.e., the user can only see the value not edit it.


This form attribute is used for specifying a placeholder value that will be displayed inside the widget. Usually, it is used for stating the purpose of the widget. The placeholder text disappears once the user starts to input data into the widget.


The size attribute is used for setting the physical size of the widget. It differs from widget to widget. The input widget uses size to determine the number of characters that will be visible. The select widget uses size for the number of options to be displayed.


The length attribute is used for maximum quantity allowed input. It is used for limiting text input to an input widget or textarea widget.


The cols attribute is used for specifying the number of columns to be displayed in the textarea. It refers to the number of characters that could be in a single line of the textarea. The default is 20.


This form attribute works similar to the cols attribute. It provides the number of rows to be displayed in the textarea.


This attribute is used in the textarea widget to specify how the text will be wrapped. It accepts hard and soft as its values. The default is the soft wrap.


The required attribute is used for specifying that a widget should be filled before it can be submitted.