Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent generating inline CSS in Datatables

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?

like image 296
developarvin Avatar asked Oct 16 '25 13:10

developarvin


1 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!

like image 105
Brian Powell Avatar answered Oct 18 '25 16:10

Brian Powell