I have created a custom jQuery plugin that enhances table operations, similar to a grid plugin.
The plugin applies styles such as overflow:hidden;
to cells and adds borders to the table and its cells. To ensure consistent border widths, I included the following CSS rules:
.MyTable {border-width:0 0 1px 1px;}
and .MyTable > tr > td {border-width:1px 1px 0 0 }
.
Now I am pondering how and where to integrate these CSS styles.
I could place them in an external CSS file, but this would require users to add it to their pages. This could present a barrier for new users who may forget to include the CSS file or potentially modify its contents, causing the plugin to function improperly.
Additionally, I want to offer users the flexibility to customize aspects like the border width. If I opt for an external CSS file, users can freely make changes. However, placing styles directly on the jQuery element using elem.css(...)
avoids the need for users to interact with a CSS file. Yet, this approach merges functionality with design, leading to less efficient code.
Are there alternative methods to apply styles to jQuery plugins?
What is the most effective approach to take?
I am specifically referring to styles necessary for the structure of the plugin, rather than those related to color or font choices!