HTML में Form बनाने के लिए <form> tag का use किया जाता है। Form की help से हम अलग अलग तरह का user data like name , age , address etc ... server पर processing के लिए send कर सकते हैं।


मतलब जब हम web development करते हैं तो हमें कई तरह का data database में या किसी दूसरी process के लिए form की करूरत पड़ती है।


Form data handle करने के लिए हैं server side language जैसे कि PHP , Java , Python etc ... की जरूरत पड़ती है। इनमे से PHP को आप हमरी website से पढ़ सकते हैं।

HTML <form> Tag

जिस तरह table या list create करने के लिए हम <table></table> tags के अंदर content लिखते हैं उसी तरह से किसी भी web page में form create करने के लिए <form></form> tag का use किया जाता है | यह एक तरह से container होता है जो HTML form का starting and ending होता है। form tag के अंदर ही हम सभी inputs (like : input , textarea , checkbox etc..) लिखते हैं। पर form tag के कुछ attributes भी होते है |

HTML Form Syntax

<form action="path" method="get/post">

...your other fields

</form>

Form Attributes

Form को handle करने के लिए HTML में कुछ form attributes इस प्रकार हैं -

HTML form action Attribute

action attribute से हम form की location define करते है means form submit होने के बाद हम किस location पर form के साथ submit data को handle करेंगे। वो location हम action attribute में देते हैं।

HTML Form method Attribute

method attribute के द्वारा हम define करते हैं कि form किस तरह की request बनाएगा। basically request 2 तरह की होती है - get और post . By default form get type के method के साथ submit होता है means अगर आप method attribute define नहीं भी करते हैं तो भी form get type की ही request के साथ submit होगा।


post type की request के साथ form submit करने के लिए आपको method="post" लिखना ही पड़ेगा।

HTML Form Example

File : html_form.html

Copy Fullscreen Close Fullscreen Run
 <!DOCTYPE html>
<html>
  <head>
	<meta charset="utf-8">
	<title>HTML Table Example</title>
  </head>
  <body>
	<form action="location" method="post">
	  <label>First Name</label>
	  <input type="text" name="fname" placeholder="Enter Your First Name">

	  <label>Last Name</label>
	  <input type="text" name="lname" placeholder="Enter Your Last Name">

	  <button type="submit">Submit</button>
	</form>
  </body>
</html> 

हालाँकि different - different data के लिए different - different form inputs होते हैं जिन्हे आप next topic में detail में पढ़ेंगे। Example में <lable> का use input के labeling के लिए किया गया है और input tag का use data enter करने के लिए है जिसका type text है means इस input में हम string / text input कर सकते हैं।


अगर आप जाना कहते हैं कि form को कैसे handle करते हैं तो आप PHP का topic Form Handling पढ़ सकते हैं।


तो कुछ इस तरह से HTML में हम forms बनाते हैं , next topic में हम different - different form input के बारे में पढ़ेंगे।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers