HTML Form Attributes

By | January 10, 2020

Form elements in HTML are those that are used in the form, with the help of which we can pass our message to another user.

HTML action:-

The action attributes in the HTML form are those in which a link to the file is given where the file has to go. The action contains a URL that can be a php etc. file.


<form action="action.html" method="post">
	<label>Name:</label>
	<input type="text" name="name">
	<label>Mobile No:</label>
	<input type="tel" name="mobile-no">
        <input type="submit">
</form>
	

Output:-

form

HTML method attribute:-

method attribute in HTML is taken inside the form tag. Which defines the HTTP method used to submit browser form. If we want to show the data in the URL after submitting the form then we can use these method.

post:-

<form action="action.html" method="post">
	
</form>

get:-

After submitting this form the data appears in the URL it is not very secure.

<form action="action.html" method="get">

</form>
	

_self: It shows the data at present.

<form action="action.html" method="get" target="_self">

</form>
	

_blank: It opens the data in a new page or it opens a new page.


<form action="action.html" method="get" target="_blank">

</form>
	

HTML placeholder attribute:-

It add a path inside the input.It represents the value in the input by default.

<form>
<label>Name</label>
<input type="text" name="name" placeholder="Your Name"><br><br>
<label>Email</label>
<input type="email" name="email" placeholder="Enter Email">
</form>
	

HTML disabled attribute:-

It is used to disable any input or an element. This attribute is not clicked.



<form>

<label>Name</label>
<input type="text" name="name" placeholder="Your Name" disabled>

</form>
	
	

Output:-

form

HTML size attribute:-


<form style="width: 50%;">

<label>Name</label>
<input type="text" name="name" size="30">
<br><br>
<label>Email</label>
<input type="email" name="email" size="60">

</form>

Output:-

form
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *