It's such a common sight, you probably don't think twice. You swat at the fly buzzing around your head, and it seeks refuge on the ceiling. You stomp at an ant crawling along the baseboard, and it escapes by climbing the wall. Insects seem to respect the law of gravity about as much as someone with diplomatic immunity respects a local jaywalking ordinance. How do they get away with it?
Actually, flies and ants need to obey the same law of gravity that we do. The gravitational tug anything feels is directly proportional to its weight though. Because household insects weigh so much less than we do, it takes only a very small amount of force to overcome gravity and keep them stuck to the wall or ceiling. This force is easily provided by special structures on the tips of the insect's legs, called the tarsi.
On the tip of each leg, every fly has a tiny set of claws, which you can see with a magnifying glass. These grip the surface the same way a rock climber might grip a cliff face with her fingertips. Each of these tarsi also has a tiny, sticky cushion. You might think that these cushions are suction cups, but they aren't. They're merely sticky enough to hold the minuscule weight of the insect.
Flies tend to rely more on these cushions to keep them up, while ants tend to favor their sets of claws, although both insects have both sets of equipment. Their biggest aid, however, is their minuscule weight. Spiderman notwithstanding, for wall crawling, smaller is definitely better.