gpt4 book ai didi

css - 对多个 HTML 标签使用相同的 ID?

转载 作者:太空狗 更新时间:2023-10-29 13:54:51 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Several elements with the same ID responding to one CSS ID selector

下面是我正在测试的示例代码,我感到很困惑。每个人都说我们可以使用或每个 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 选择器,而它工作正常。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com