how cache detect forms inputs like firstname and lastname and distribute value in them

when we hover on form in any website the dialog box is displayed and when we click on that dailog box. input fields are detected like first name or last name or may be address .My question is that how browser detects the exect input field and distribute values in them .like using name , id type of input field or other process are used .if possible give some references too.thanks
js developers..web

how cache detect form fields and distribute inputs.