What does the localhost username do?

I noticed that if I press enter while my cursor is in the input, the url changes to

https://localhost/?username=

where is whatever I have typed in the input box. When I tried changing the url to

https://localhost/?username=Testing

I had expected that the page would load with the input box having a value of “Testing”, but this was not the result.

What exactly is going on here?

After further experimenting, I noticed something which seems to be a bug: After changing the input element to have no predefined value

<input type="text" name="username">

and then clicking the refresh button on the browser panel, the page still loaded with “Davie” appearing in the input box. Is this unintended behavior or am I missing something here?

If the described behavior is unclear, here is a gif to illustrate: https://gyazo.com/06decf8bb6d9d7c313b8709bd6450ebb

1 Like

They are different in that id is used to assign a unique name to an element which will then be worked with CSS code, for example. While name is an attribute specific to some elements, like the <form> element and is used to have a name to assign the input value to.

More here: https://stackoverflow.com/questions/1397592/difference-between-id-and-name-attributes-in-html

1 Like