Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果多个HTML标记位于不同的文件上,它们是否可以具有相同的ID?_Html_Tags - Fatal编程技术网

如果多个HTML标记位于不同的文件上,它们是否可以具有相同的ID?

如果多个HTML标记位于不同的文件上,它们是否可以具有相同的ID?,html,tags,Html,Tags,如果它们位于包含网站的目录中的两个不同页面上,在不同的HTML文件中,是否可以为它们提供相同的ID 例如: index.html: <div id="exampleDiv"></div> 第2.html页: <div id="exampleDiv"></div> <!-- same ID as in index.html --> 答案很简单:是的 id在一个文件中必须是唯一的,但不能跨不同的文件,只要不是一个文件包含另一个文件。如果

如果它们位于包含网站的目录中的两个不同页面上,在不同的HTML文件中,是否可以为它们提供相同的ID

例如:

index.html:

<div id="exampleDiv"></div>
第2.html页:

<div id="exampleDiv"></div> <!-- same ID as in index.html -->
答案很简单:是的


id在一个文件中必须是唯一的,但不能跨不同的文件,只要不是一个文件包含另一个文件。

如果在不同的文件中,例如index.html和page2.html,它们可以在两个页面上具有相同的id


但是,如果要将page2.html包含到index.html中,则不可以复制id。

可以。他们只需要引用css文件

@ianaya89为什么不呢?可能是