+ 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

6th Sep 2022, 1:00 PM
Ravi Kshiwak
Ravi Kshiwak - avatar
9 ответов
+ 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 ?
6th Sep 2022, 1:18 PM
Ravi Kshiwak
Ravi Kshiwak - avatar
+ 4
no... there aren't any differences ... you can write them in any order
6th Sep 2022, 1:22 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 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.
6th Sep 2022, 1:32 PM
PanicS
PanicS - avatar
+ 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.
6th Sep 2022, 1:24 PM
Tyler McKechnie
6th Sep 2022, 1:29 PM
Ipang
+ 2
Thank you all for making the point clear
6th Sep 2022, 2:13 PM
Ravi Kshiwak
Ravi Kshiwak - avatar
+ 1
if type isnt specified for input element . its implicitly is text ...
6th Sep 2022, 1:04 PM
Prashanth Kumar
Prashanth Kumar - avatar
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
8th Sep 2022, 1:46 AM
Victory Oseiwe
Victory Oseiwe - avatar
0
Thank you Victory
8th Sep 2022, 10:11 PM
Ravi Kshiwak
Ravi Kshiwak - avatar