CSS类和id具有相同的名称 [英] CSS class and id with the same name

查看:89
本文介绍了CSS类和id具有相同的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个css类和id有相同的名称有什么问题吗?

Is there anything wrong with having a css class and id with the same name? Like .footer for the article/post's footer and #footer for the page footer.

推荐答案

不完全可以接受。

类使用定义,ID使用。因此,就浏览器而言,它们是两个完全独立的项目。

A class is defined using a . and an ID is defined using a #. So as far as the browser is concerned, they're two totally separate items.

唯一需要注意的就是为自己造成混乱。这可能是最好的做法是保持名称不同纯粹为代码可读性,但没有危害在他们是一样的。

The only thing to be careful of is generating any confusion for yourself. It's probably best practise to keep the names different purely for code readability, but there's no harm in them being the same.

这篇关于CSS类和id具有相同的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆