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

后端 未结 8 1672
不思量自难忘°
不思量自难忘° 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条回答
  •  -上瘾入骨i
    2021-01-29 11:53

    You have heard correctly. The behavior you are seeing is the result of browsers being coded to be extremely accommodating in the face of gross violations of the HTML standard.

    The idea behind the fact that they have been coded to work even when presented with "bad" data is that, to less technically proficient users, it's the browser's fault if something does not work. Browsers were forced to work with tag soup, and this is the logical extension.

提交回复
热议问题