Create a Form Element. What is Form in here?

Tell us what’s happening:

I got the codes, but i didnt knew that what is the tasks of Form in here?

Your code so far

  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <p>Things cats love:</p>
    <li>cat nip</li>
    <li>laser pointers</li>
  <p>Top 3 things cats hate:</p>
    <li>flea treatment</li>
    <li>other cats</li>

  <form action="/submit-cat-photo"> 
  <input type="text" placeholder="cat photo URL">

In this example, you are creating a form where the user can input the URL of an image, and then submit it to the site. You aren’t learning the back-end programming that makes this function, you’re setting up the front-end that allows a user to perform the input.

Using <form> tags is correct for semantic and accessibility reasons. It allows your code to be easily read by others, and allows disability tools like a screen reader to understand that this section of your website is a form.

It also has functional purposes. For example, any website that allows you to enter text and then use the “enter” key to “click” a button rather than clicking the button directly is probably using the <form> tag to associate the input field with the submit button.

1 Like