下面是我正在测试的示例代码,我很困惑。每个人都说我们可以使用或者我们应该每个 id 只使用一次,但是我有测试多次使用它,但它给了我正确的输出。
我应该怎么办?
在这个例子中,它对我来说有点像课堂一样
代码:
<html>
<head>
<style>
#exampleID1 { background-color: blue; }
#exampleID2 { text-transform: uppercase; }
</style>
</head>
<body>
<p id="exampleID1">This paragraph has an ID name of "exampleID1" and has a blue CSS defined background.</p>
<p id="exampleID2">This paragraph has an ID name of "exampleID2" and has had its text transformed to uppercase letters.</p>
<address id="exampleID1">
Written by W3Schools.com<br />
<a href="mailto:us@example.org">Email us</a><br />
Address: Box 564, Disneyland<br />
Phone: +12 34 56 78
</address>
<blockquote id="exampleID1">
Here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation.
</blockquote>
</body>
</html>
请查看上面的代码并回答我为什么我们不应该在一个页面中使用两次 id 选择器而它工作正常。