收录日期:2019/04/26 16:16:21 时间:2010-06-16 02:04:58 标签:jquery,css,jquery-ui,jquery-plugins

While creating a jQuery widget, what convention should I use to name my CSS classes. jQuery uses a 'ui-' prefix followed by the plugin name and a class specific name (example : ui-datepicker-header).

Should I use this convention? Or is the 'ui' prefix "reserved" for jQuery's official use only?

When deciding things like this, think about how someone knowing nothing about your code would read it.

I wouldn't use the "ui-" prefix because such a person might think it's jQuery UI related.

You don't need to use a prefix. In most cases this is "noise". If everything starts with "foo-" why have it? It makes sense for a library because then you can easily distinguish what "belongs" to the library. For your own code, it's assumed that everything that doesn't belong to a library belongs to your application.

Pick a meaningful name for each thing that is short but not too short.

Avoid using "reserved" one, use your own but make sure that overall name does not conflict with any of existing plugins/widgets.