Form Attributes

Next ❯HTML Blocks

  • 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

    <form  action="anyActionURL">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    OUTPUT
    Email :
  • label_outline"accept-charset" Attribute

    To set the character encoding for the form submission

    <form accept-charset="UTF-8">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    OUTPUT
    Email :
  • label_outline"enctype" Attribute

    To set the form data encoding type, only for 'POST' method

    <form method="post" enctype="text/plain">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    
    OUTPUT
    Email :
  • label_outline"method" Attribute

    To set the form sending method

    <form method="post">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    
    OUTPUT
    Email :
  • label_outline"name" Attribute

    To set the form name

    <form name="formName">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    
    OUTPUT
    Email :
  • label_outline"target" Attribute

    To set where to open the response after submitting the form

    <form target="_blank">
      Email : <input type="email" name="mail">
      <input type="submit" value="Submit">
    </form>
    
    OUTPUT
    Email :


Input element Attributes

Attributes for input element

  • label_outline"type" Attribute

    To set the type of input

    <form>
      First name: <input type="text" name="first_name">
    </form> 
    OUTPUT
    First name:
  • 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

    <form>
      First name: <input type="text" name="first_name">
    </form> 
    OUTPUT
    First name:
  • label_outline"value" Attribute

    To set the initial value for an input field

    <form>
      User name: <input type="text" name="username" value="rahul">
    </form> 
    OUTPUT
    User name:
  • label_outline"readonly" Attribute

    To set the input field only to read (can't be changed)

    <form>
      Message : <input type="text" name="message" value="You can only read this.." readonly>
    </form>  
    OUTPUT
    Message:
  • label_outline"disabled" Attribute

    To disable the input field

    <form>
      Message : <input type="text" name="message" value="This input is disabled" disabled>
    </form>
    OUTPUT
    Message:
  • label_outline"size" Attribute

    To set the visible size/width (in characters) for the input field

    <form>
      Message : <input type="text" name="message" size="10">
    </form>
    OUTPUT
    Message :
  • label_outline"maxlength" Attribute

    To set the maximum length for the input field

    <form>
      Message : <input type="text" name="message" maxlength="10">
    </form>
    OUTPUT
    Message :
  • label_outline"height,width,src" Attribute

    To set the height, width and source of image type

    <form>
      <input type="image" name="imagebutton" src="images/imageFile.png" height="50" width="50"/>
    </form> 
    OUTPUT
    • here, the above image act as a image button
Browsers Supports
SafariMicrosoft EdgeMozilla FirefoxChromeOpera Mini

Click on the above icon to see the name of the browser !

  • Tips! Always try to use latest version of browser

  • HTML Blocks
❮ Prev Form Elements
Next ❯HTML Blocks
TryOut Examples"Learn to Explore..!"

TryOut Editor

receipt