ID vs CLASS in CSS. Please explain in detail with example

后端 未结 8 1665
不思量自难忘°
不思量自难忘° 2021-01-29 11:46

I have heard that ID is unique and can only be used once in a page, but its working fine when used over multiple times on a page. Please let me know the purpose of ID and hows i

8条回答
  •  北海茫月
    2021-01-29 12:07

    An ID is used to reference certain elements when using JQuery / Javascript etc, so technically if you wish to utilise these features then IDs on your page should be unique.

    If you are only bothered about styling then it really isn't a huge issue, although it isn't valid practice.

提交回复
热议问题