I noticed that Datatables sometimes generates inline CSS (style='....'). Is there are way to remove them? Or at least make the code not add styles inline?
2 Answers
There are a few options in DataTables to turn off the element.style that generates with a table's generation. I've found that setting bAutoWidth : false can sometimes turn off all of the inline styles, (even though it's just meant to turn off the inline width option), as well as initializing the table outside of $(document).ready(function().
As for a single option to turn off all styles created by DataTables - I'm not sure there's a way to do that, but if someone else finds this old thread, try these two options and see if it fixes your problem!
1 Comment
The most accurate answer would be: yes, the code can be changed to stop adding style=... to the html BUT removing all of them would almost certainly break the datatable layout and its behavior.
Datatable plugin uses style="..." to set dynamic properties (like width, position) that (in most cases) cannot be determined before actually running the plugin. If they cannot be determined they cannot be styled beforehand using css classes so we end up in using style="..." for those.