CSS class and identifier with the same name

Is there something wrong with having a css class and an id with the same name? Like .footer for the footer of the article / post and #footer for the footer of the page.

+49
css class
Jul 15 '10 at 8:30
source share
3 answers

No, totally acceptable.

The class is defined with . , and the identifier is determined using # . As for the browser, these are two completely different elements.

The only thing to be careful about is to create confusion for yourself. It is probably best practice for the names to be different for the purity of the code, but there is no harm.

+68
Jul 15 2018-10-15T00:
source share

No, there is nothing wrong, but it would be better to use different names so as not to confuse other developers. This is a big (human) error, prone to use different names.

+11
Jul 15 2018-10-15T00:
source share

Yes, you can use the same name for id and class , because both parameters have their own value. Thanks

0
Jun 12 '17 at 8:59 on
source share



All Articles