Sophie-Jane, of Milton Primary School, asks :-
If we leave Earth, will there be gravity in outer space?
Marlyn Jakub, a physicist at Otago University, responded.
Yes, you would still be affected by Earth's gravity force even as you left Earth's surface far behind. However, Earth's gravity would cause a smaller attractive force the farther you traveled. Eventually, your travels could take you near other large planets or sun-stars, where you would again experience similar large gravity-caused forces, for what we call 'gravity' is the attractive forces between any two masses.
On the surface of the Earth, the main attraction is between the mass of the Earth and any object at the Earth's surface. You, your house and even the atoms in the air are attracted towards the Earth. The strength of attraction also depends on the distance between the object and the centre of the planetary mass...that is, the distance to the centre of the Earth. As the distance from the object to the centre of the planet increases, the attractive force becomes much smaller, but does NOT vanish altogether. Even the distant Moon and the even-more-distant Sun exert attraction forces on objects at the Earth's surface. These Moon and Sun forces explain the rise and fall of ocean tides at the surface of the Earth.
Another way to appreciate the action of attractive forces is to recognize that the Moon circles around the heavier Earth--both objects held in these orbits by the attractive force between the two masses. Similarly, the Earth and other planets circle the Sun, held in orbits by the gravity-caused attraction forces between the massive Sun and each smaller planet. Galaxies also demonstrate the gravitational attraction forces, as the millions of star-suns bunch together in a swirling masses of objects held together by their mutual attraction.
So gravity exists throughout space, but the attraction force only gets quite large when the object or person travels near one of the large heavenly bodies.