Organization of names and identifiers of HTML classes used for different purposes (appearance, jQuery and Selenium)

There are many articles about writing pure HTML / CSS.

What I have not yet found are tips on organizing class names and identifiers that are used for different purposes (design vs jQuery vs Selenium).

For any class name and identifier, it is difficult to determine what it is used for. In teams of 2+ people, there is also a tendency to add more and more identifiers and classes and to avoid cleaning up those that already exist, for fear of breaking things.

Are there patterns, conventions, tools, or pearls of wisdom that will help?

+4
source share
2 answers

I did not come across tools that help in this situation. But I used the conventions below with moderate success. However, none of them is an exact science.

Regarding identifiers:

Since identifiers are faster, I try to use them every time I want to access a certain part of my HTML, no matter how I use it (styling / jQuery / testing / etc).

However, since each element can have only one identifier, there is really no way to use the convention or naming style for different purposes. And I found that if I wanted to refer to an element for one reason, I have a chance that I want again for another reason.

: jQuery ( ), , , , .

, , , , , . , .

, ,

,

, . , , , .

, HTML. (, , , , )

, - , , . , "" .

:

2+ , , ... , , .

; , . , , , , . , , , , : " , ". .

, ID ( ), :

  • ,
  • , , " "
  • ( )

, "" , , , "tst". , :

  • ()
  • , ( , )
  • ,

- , , ( ). - , - , , , .

TL;DR;

, , , . , !

+1

: ( HTML- ) , id ( Selenium), " /" - , .

- , - , ( "" - ) CSS .

- - . - id ...

+1

All Articles