In this fiddle: https://jsfiddle.net/9erLby1o/4/, using JS I add if needed an overflow property. If the container of my table is smaller than the width of table. this is done in the following js lines:
for(var el=0; el<document.querySelectorAll("table").length; el++){
if (document.querySelectorAll("table")[el].parentElement.offsetWidth < document.querySelectorAll("table")[el].offsetWidth ){
document.querySelectorAll("table")[el].parentElement.classList.add("overflow");
}
}
I would like to know if something like that is possible in pure CSS.
I am a bit influenced by the checkbox hack which implies if statement but I cannot access the properties of the elements in css so I would like to see how and if I could use it in this context.
Lastly I would like to know why I should prefer CSS than javascript in this scenario. (The only possible reason I can think is that since CSS use is inevitable it should be able to handle all the style of the application. But I may be wrong)