Density is the amount of stuff within a specified space. If you pack a lot of stuff into a space, you will have a dense space. If the space gets smaller or if you add more stuff, the density increases; it’s a pretty easy concepts to understand. Density, coupled with gravity, is the reason anything has weight. To explain this, we’ll have to start on the subatomic level.
The universe is mostly empty space. It takes light a full second to travel between the Earth and moon. To give a little perspective, in the same amount of time, a light beam can travel around the Earth 7.5 times!
I want you to try and imagine a professional football stadium. It’s big right? If you place a penny at center field of the stadium, you would have a decent representation of the size of the nucleus within an atom. The nucleus is about 100,000 times smaller than the rest of the atom. Within that nucleus are the hadrons, three quark clusters that we call protons or neutrons depending on their attributes. Most of the mass of an atom is within that nucleus. Electrons have mass as well but they are about 2000 times less massive than a hadron, so we’re going to ignore them for now.
Different elements have different numbers of protons and neutrons within their nuclei. Looking at multiple atoms, the ones with more hadrons still stay within roughly the same nuclear space. Gravity is a fundamental force of the universe that attracts mass, so atoms with more mass within their nuclei are going to be attracted with a greater force. This is why “heavier” elements are heavier! A block of charcoal weighs significantly less than a similar sized block of silver. This is obvious since silver atoms have 39 more protons than carbon atoms, plus all the additional neutrons. Gravity gives objects weight, their mass stays the same. This is why astronauts can bounce around while on the moon: smaller object, less pull.
Density can also be affected by the position of atoms. Atoms closer together will be denser than atoms that are further apart. Solids are closely packed atoms that are bound together while gases are unattached atoms bouncing around in all directions. This means that solids are denser than gases. Liquid is somewhere in the middle, though water is a weird one with a less dense solid form.
You are already aware of density’s consequences from gravity. The dense, solid ground is pulled closer to the center of the planet than the liquid water that sits on top of it. The gaseous air is even less dense than both liquid and solid so it has a weaker pull from gravity and sits on top of both forming our atmosphere.
You have probably experimented with gravity and density before. If you are swimming in a pool and hold your breath, you will float to the top. The water is denser than the air in your lungs so it will be pulled underneath you, pushing you upward. In order to swim down, you must breath out some of that air. The air then travels upward in bubbles for the same reason. Boats are able to float because they have air within their hulls which is less dense than the water they’re floating on.
It’s an amazing feeling when you discover that the fundamental parts of our understanding are actually caused by the fundamental aspects of our universe. The goal of science is to encourage you to ask questions, and the best part is that every answer will always bring up more questions.