HTML - using name for identifier and class

Is it OK to use the same name for the class name and name? Is that the smell of code?

<div class="wrapper" id="wrapper"></div>
+3
source share
6 answers

Yes this is true. This is not often done, though: it is a bit of code smell . This may indicate a need to review your naming conventions.

To expand on the subject of naming conventions and semantics:

When you use an identifier wrapper, you say, "This shell is one of a kind." When you use a class wrapper, you say: "This is one of the wrappers, and there are others like that." Saying both of these things at the same time is a little strange, right?

, : #primaryWrapper, #outerWrapper .. , "primaryWrapper - ", .

+8

, ,

, , #ID , .CLASS .

HTML, .

+6

, . , .

+3

, , , , . , . wrapper1 a wrapper2, .

+3

, .

, , .

:

, .

id , javascript.

+1
source

All Articles