apa is the difference between the id and also name attributes? lock both it seems ~ to offer the same objective of giving an identifier.

Anda sedang menonton: Perbedaan .com dan .id

I would like to understand (specifically v regards come HTML forms) even if it is or not melihat both is necessary or motivated for any kind of reasons.



The name attribute is tangan kedua when sending out data in a form submission. Berbeda controls respond differently. Because that example, you may have actually several radio buttons with different id attributes, but the exact same name. When submitted, there is hanya the one worth in the solution - the radio button you selected.

Of course, there"s an ext to it 보다 that, but it will certainly get you reasoning in the appropriate direction.



Use name characteristics for membentuk controls (such as and also ), as that"s the identifier used in the post or GET panggilan that wake up on form submission.

Use id qualities whenever you require to address a details HTML element with CSS, JavaScript or a bagian-bagian identifier. It"s mungkin to watch up elements by name, too, but it"s easier and much more reliable to look them up by ID.


Here is a short summary:id is used to identify the HTML aspect through the DocumentObject Model (via JavaScript or styled v CSS). I would is expectedto be unique within the page.

name corresponds to the form element and also identifies what is postedback come the server.

The way I think about it and use the is simple:

id is used for CSS and JavaScript/jQuery (it needs to be unique on a page).

name is used for form handling top top the server as soon as a form is it is registered via HTML (it needs to be unique in a membentuk - to some extent, view Paul"s comment below).

See id= vs name=:

What’s the difference? The short answer is, use both and don’t worry about it. But if you desire to understand this goofiness, this is the skinny:

id= is for usage as a membidik like this: for links like this: .

name= is also used to merek the fields in the blog post send come a server through an HTTP (HyperText transfer Protocol) obtain or write-up when girlfriend hit send in a form.

id= labels the areas for usage by JavaScript and Java DOM (Document object Model).The name in name= have to be distinct within a form. The names in id= should be unique within the whole document.

Sometimes the name= and id= names will differ, due to the fact that the server is expecting the exact same name indigenous various formulir in the same file or variasi radio buttons in the same form as in the example above. The id= should be unique; the name= must not be.

Lihat lainnya: Surah Al Alaq Ayat 5 - Surah Al 'Alaq Ayat 5

JavaScript needed distinctive names, however there were too plenty of documents already out di sini without distinctive name= names, so the W3 setiap orang invented the identifier tag that was required to it is in unique. Regrettably older browsers walk not recognize it. So you require both specify name schemes in your forms.