Gravity is caused by mass: the bigger/heavier an object is, the more powerful its gravitational field. This was first shown by Newton and then Einstein refined the explanation to deal with a few things not which couldn’t be explained. So gravity is not to do with planets, it’s to do with mass. Even the moon has a gravitational field, it’s just weak!
Comments