Day 6: HTML Forms :Name attribute :Placeholder attribute :

 HTML Forms :

  • An HTML form is used to gather input from the user.     
  • <form> tag is used for creating an HTML form which can allow users to input data.    <form> tag can contain different types of different elements, like text fields, radio buttons, checkboxes, submit buttons, etc.           
  • Type attribute of <input> defines the various ways in which <input> elements can be shown.     
  • Various attribute values for the “Type” attribute are mentioned below :

  1. <input type="text"> 

It creates an input field supporting single-line text.

 2. <input type="radio">

Creates a radio button (can select only one choice with radio button)

3. <input type="checkbox">

Creates a checkbox (can select zero or multiple choices)

4. <input type="submit"> 

Creates a submit button (for submitting data in form)

5. <input type="button"> 

Creates a button

 

Name attribute :

  • Name of an HTML element is defined by the name attribute.

 

Placeholder attribute :

  • This attribute gives a hint to the user, stating the value to be expected from the user for an input field. (expected input format).             
  • Hint is shown in the input field before value is entered by the user.
  • Example:
    Code:

    <form>

            <input type="text" placeholder="First Name"

            <br>

            <input type="text" placeholder="Last Name">

    </form>

The <textarea> Element :

  • It is used to create a field which can contain multiple lines.
  • Example:

    <textarea name="anyName">

    Creates a textarea with 30 rows and 20 columns

    </textarea>

     

Difference between input type=”text” and textarea :

  • Textarea can contain multiple lines in it, whereas input type=”text” is used to contain only one single line.

 

The method Attribute

  • It describes how to send data through form.       
  • Data collected through form can be sent using GET or POST method. 

 

GET method :

  • After a form is submitted using the GET method, its values are visible in the address bar of the new tab of the browser.       
  • It should be used for sending data which is not secured, and not for information that is sensitive. 
  • Syntax :
    <form method=”GET”>

 

POST method :

  • After a form is submitted using the POST method, its values are not visible in the address bar of the new tab of the browser.   
  • Syntax :
    <form method=”POST”>

Comments

Popular posts from this blog

else-if condition in if-else statements: Concatenation in JavaScript :

Day 9: CSS - Font Formate

Day 28: CSS Animation, CSS Transition Animation Box size