开发者

Correct Tag Use When Creating A Form In HTML?

开发者 https://www.devze.com 2023-03-06 05:35 出处:网络
English isn\'t my native language so I\'m little confused when I see tags like... form, input, textarea, select, fieldset, label etc..

English isn't my native language so I'm little confused when I see tags like...

form, input, textarea, select, fieldset, label etc..

Can you enlighten me and tell me when, why and how to use these tags to make HTML form. It's more like a SEO question even... You know, you could write like:

<form ...>
  <p><input type="text" /></p>
  <p><input type="password" /></p>
  <p><button>I Won't Bite!</button></p>
</form>

But Google 开发者_开发知识库won't be happy and I'm 100% sure that it won't be correct neither. Yes, it would work, because you can style your tags to act like anything with CSS, but it still isn't correct... Enlighten me, good people!


I think the reference you're looking for is the HTML spec on the <form> element.

If you're not sure if your markup is semantically valid, you can check it using the W3C Makrup Validator, but it's generally not worth making your markup 100% valid — much more important to create a page that looks and works reasonably consistently across browsers.

As for SEO, there is a ton of relevant questions on SO already, such as What is the best way to structure an HTML document for SEO and accessibility?


 <form action="W" method="X"></form>

HTML forms are pieces of codes that can be used in various functions. The most common use for is to send data to another page using GET method or POST method.

The form action value W would be replaced with the URL of the processing script. The form method value X would be replaced with GET or POST.

<input type="text" />

The text field to get input from user.

<input type="password" />

The password field by itself only hides the text on the users screen A secure link between the browser and server is a seperate matter

 <textarea>

This puts text on a single line until the enter key is pressed

The <select> tag is used to create a select list (drop-down list).

The <option> tags inside the select element define the available options in the list.

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

The <fieldset> tag is used to logically group together elements in a form. The <fieldset> tag draws a box around the related form elements.

  <fieldset>
    <legend>Personalia:</legend>
    Name: <input type="text" size="30" /><br />
    Email: <input type="text" size="30" /><br />
    Date of birth: <input type="text" size="10" />
  </fieldset>

The <label> tag defines a label for an input element.

  <label for="male">Male</label>


SEO is for optimization of content so that search engines can find important keywords in the content. There is no real value in optimization of forms because that is just a markup to define input fields for user. Form is for posting data to the server. I think that many search engines even skip forms.


I kow this is very old question. You can use asterisk '*' and space this will give you bullet point

example

/** Here is one line
* * point one
* * point two
*/

below will be the result.

Here is one line

  • point one
  • point two
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号