+ 1
New question friends
I learnt both these 2 ways from a coding app. Can any once tell me if there is any difference between these two ways ? Code is public https://code.sololearn.com/Wyh1M4KvYX0g/?ref=app
9 Answers
+ 4
Thank you Prasanth,
I meant to say
<input type="password" placeholder="Password">
<input placeholder="Password" type="password">
Are these two same ? Or some special difference is made by writing them differently ?
+ 4
no...
there aren't any differences ...
you can write them in any order
+ 4
Order of attributes inside html tag is not important, you can type it in any order you like.
One of practice if you have many attributes is to type them in new line, so you can easy see them.
<input
id="password"
class="input-field"
type="password"
placeholder="Password"
/>
Now you can easy change something, you don't have to scroll horizontally.
Also, if you don't set type attribute for input element, default will be type="text", but is best practice to set it, so search engines will understand your page better.
+ 3
So, when you specify the type of input you're expecting to receive from the user, the input area behaves in slightly different ways.
For example, type "text" is standard and expects any kind of string from the user. Type "password" also takes in a string, but the browser will display whatever the user inputs with dots (●●●●●) to maintain privacy.
There are other input types as well, such as "date", "email", "number", "radio", and others that will present the input prompt in specific ways or only allow responses formatted in certain ways or that contain certain types of characters, etc.
+ 2
Adding after Tyler ...
https://www.w3schools.com/html/html_form_input_types.asp
+ 2
Thank you all for making the point clear
+ 1
if type isnt specified for input element .
its implicitly is text ...
0
Ravi Kshiwak I will say they aren't the same and here is why your first code specified the type of input you want for your email <input type="text" placeholder="Email"><br>
<input type="password" placeholder="Password"><br>
👆👆👆👆 Your first code
Then the second code doesn't have have any type referring to it so user could also enter their mobile number in place of email and it would still work
<input placeholder="Email"><br>
<input placeholder="Password" type="password">
👆👆👆👆 Your second code
So it's important you specify the type of input you want from the users least I forgot there are also lots of type like the radio, checkbox etc.
Hope that helps
0
Thank you Victory