Form Attributes
- All the codes below are being used inside
<body>
tag - Alert! Your output appearance will be different because of not using CSS. So, Don't get confuse
Form element Attributes
Attributes for form element
- label_outline"action" Attribute
To set the URL to which form is submitted
OUTPUT<form action="anyActionURL"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
- label_outline"accept-charset" Attribute
To set the character encoding for the form submission
OUTPUT<form accept-charset="UTF-8"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
- label_outline"enctype" Attribute
To set the form data encoding type, only for 'POST' method
OUTPUT<form method="post" enctype="text/plain"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
- label_outline"method" Attribute
To set the form sending method
OUTPUT<form method="post"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
- label_outline"name" Attribute
To set the form name
OUTPUT<form name="formName"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
- label_outline"target" Attribute
To set where to open the response after submitting the form
OUTPUT<form target="_blank"> Email : <input type="email" name="mail"> <input type="submit" value="Submit"> </form>
Input element Attributes
Attributes for input element
- label_outline"type" Attribute
To set the type of input
OUTPUT<form> First name: <input type="text" name="first_name"> </form>
- label_outline"name" Attribute
To set the name of the input field, which is used as a key to access the data at server side
OUTPUT<form> First name: <input type="text" name="first_name"> </form>
- label_outline"value" Attribute
To set the initial value for an input field
OUTPUT<form> User name: <input type="text" name="username" value="rahul"> </form>
- label_outline"readonly" Attribute
To set the input field only to read (can't be changed)
OUTPUT<form> Message : <input type="text" name="message" value="You can only read this.." readonly> </form>
- label_outline"disabled" Attribute
To disable the input field
OUTPUT<form> Message : <input type="text" name="message" value="This input is disabled" disabled> </form>
- label_outline"size" Attribute
To set the visible size/width (in characters) for the input field
OUTPUT<form> Message : <input type="text" name="message" size="10"> </form>
- label_outline"maxlength" Attribute
To set the maximum length for the input field
OUTPUT<form> Message : <input type="text" name="message" maxlength="10"> </form>
- label_outline"height,width,src" Attribute
To set the height, width and source of image type
OUTPUT<form> <input type="image" name="imagebutton" src="images/imageFile.png" height="50" width="50"/> </form>
- here, the above image act as a image button
Browsers Supports
Safari | Microsoft Edge | Mozilla Firefox | Chrome | Opera Mini |
Click on the above icon to see the name of the browser !
- Tips! Always try to use latest version of browser