Is it a bad practice to use dynamically generated IDs for theming Is it a bad practice to have styles such as these in the css files ?

#block-block-1, #block-block-7, #block-block-8


I mean, if one was to delete the block and recreate it the styles would no longer be valid.

Or is it best to modify the template and target the selectors in the template ?
It is better not to use the id.

You could use this module Block Class which allows you to add a class to the block and you can then style your css using that class.