That’s right. When styles are defined in the id, there is no way to override them in any other way. Hierarchically, the id takes precedence over the classes.
You can override with !important, but it’s generally best to avoid throwing those around for much the same reason. It’s usually a sign of problems when you have to start doing that.
Alternatively, you can be even more specific in your selector like body div#foo.