The CSS appears good to me, however, you could optimize it by using the following code:
table.basicborder, th.basicborder, td.basicborder{border: 1px solid black;}
In this way, the selector begins with the least specific selector (the HTML element, rather than the class).
Assuming your HTML is properly linked, it should already be functioning correctly. Do your table, th, and td elements all have a class="basicborder"
attribute?
edit:
If I understand correctly, this would be the most efficient solution.
You establish a basic style for all elements with just table, td, th{ etc...
Then, for the ones with a different style, add a class, let's say differentborder. Next, create a CSS rule like this:
table.differentborder, .differentborder td, .differentborder th{ your style }
This targets tables with the class, as well as all td's and th's within an element with the class differentborder.
If you are interested in exploring more CSS selectors, you can refer to the W3Schools CSS Selector Reference