There is gravity in space. Gravity is everywhere. It is true that as you get farther from the earth, its gravitational pull weakens. But it dies off quite slowly (compared to nuclear forces). And gravity never goes completely away. When you get very close to some other large body; the moon, Mars, or the sun; its gravity dominates over that of the earth. Only then can you neglect earth's gravity. Because gravity is everywhere in space, objects in space are always falling, towards the earth, towards the sun, and towards the galactic center. Each galaxy is held together by strong gravitational forces. Even if you managed to get away from our sun, you would still experience the galaxy's gravity. This image is an artisitic rendition of our galaxy. Public Domain Image, source: Christopher S. Baird.