The form Element in HTML


 Create a Form Element:

  • You can build web forms that actually submit data to a server using nothing other than pure HTML.
  • You can do this by specifying an action attribute on your form element.
  • The form element has separate opening and closing tags.
  • For example:

<form action="/url-where-you-want-to-submit-form-data">
  <input>
</form>

Add a submit button to your form:
  • Let's add a submit button to our form.
  • Clicking this button will send your data from the form to the URL you specified with your from's action attribute.
  • Here is an example of the submit button:
<button type="submit">this button submits the form</button>

  • The finalized code for the form with input fields and the submit button is:

<form action="https://www.freecatphotoapp.com/submit-cat-photo">
    <input type="text" placeholder="cat photo URL">
<button type="submit">this button submits the form</button></form>

  • The output of this form will look like this:




No comments:

Post a Comment