×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / 那位大侠能给我讲讲CSS里class=和id=的区别?我看了一些书,发现他们都没有讲明白,从举的例子看两者可以通用,对吗?
    • class is used for CSS, which is the name of that style; id is used for Javascript, to identify the object in scripts.
    • You can't use them interchange. But you may also want to have a look at the name attribute, which is almost the same with id. Usually, I use both the ID and NAME, and set them to the same value.
      • 电话里谈。请email给我你的电话
    • ID is not the same with CLASS.
      The ID and the CLASS in CSS are closely related with the ID and the CLASS in a document language, such as HTML, respectively. I think that the clue for understanding CSS ID and CSS CLASS is to understand the differences between ID and CLASS in a document language first. The key difference between ID and CLASS in a document language is that ID must be unique in a document, but CLASS may not be.