HTML Experiment:
1. Create a new webpage, enter the content, open it in the browser
<HTML> <Head> <Metahttp-equiv= "Content-type"CharSet= "Utf-8"/> </Head> <Body>Name:<inputtype= "text"ID= "Intxt"/><BR/>Password:<inputtype= "text"ID= "Intxt"/> </Body></HTML>
2.
Two input boxes using the same ID number, but can display normally, the browser did not error
CSS Experiment
1. Modify the source code, add style
<HTML> <Head> <Metahttp-equiv= "Content-type"CharSet= "Utf-8"/> <style>#inTxt{Background-color:Red; } </style> </Head> <Body>Name:<inputtype= "text"ID= "Intxt"/><BR/>Password:<inputtype= "text"ID= "Intxt"/> </Body></HTML>
2.
JS Experiment
1. Modify the source code, add the script
<HTML> <Head> <Metahttp-equiv= "Content-type"CharSet= "Utf-8"/> <style>#inTxt{Background-color:Red; } </style> </Head> <Body>Name:<inputtype= "text"ID= "Intxt"value= "a"/><BR/>Password:<inputtype= "text"ID= "Intxt"value= "B"/> <Script> varinput=document.getElementById ("Intxt"); alert (Input.value); </Script> </Body></HTML>
2.
Summarize
1.html has the same ID number, does not affect the display
2.css applies a style to a label with the same ID number in the page
3. Multiple identical ID numbers, JS only go to the first one
Must the ID value be unique in HTML?