Should css class names like 'floatleft' that directly describe the attached style be avoided?

后端 未结 20 2148
谎友^
谎友^ 2020-12-13 08:32

Lots of websites use class names like floatleft, clearfloat, alignright, small, center etc that describe the

20条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 09:03

    I am a developer before a programmer, so for me I use something like a "floatleft" css class as a sort of UtilityMethod.
    Meaning, my css class is "floatleft"...and that's all that class does. so if I say

    in my mind that is saying "make this div float to the left".
    So if that Div also needs a blue background and is my main header it's going to have a different class for that and I end up with

    Doing it this way also avoids issues with refactoring. If I am changing my design later, I will know that "floatleft" ALWAYS floats things left and nothing more.

提交回复
热议问题