When it's cold out, the best way to stay warm is to wrap up in layers of clothing. This works well because each layer traps air and reduces the amount of lost heat energy. The thicker the layers and the more layers you wear, the better the insulation. The same principle applies to all objects, from enormous buildings to your cup of takeout coffee.
TL;DR (Too Long; Didn't Read)
The polystyrene foam Styrofoam is made of trapped air bubbles that prevent heat energy from flowing through it. This prevents heat loss, making Styrofoam an excellent insulator.
What Styrofoam Is
Styrofoam is the trademarked term used for polystyrene foam, a petroleum-based plastic. It is owned by The Dow Chemical Company. Styrofoam is exceptionally lightweight, an excellent shock absorber and an effective insulator, making it one of the most common plastics used in the manufacture of packing and insulating materials. Styrofoam is also thermoplastic, meaning it changes from a liquid to a solid at a certain temperature. This allows it to be molded in fine detail to make craft materials and disposable containers.
How Heat Energy Flows
Heat energy is lost—it moves from a hotter object to a colder one—in one of three ways. Conduction is the transfer of heat caused when minuscule particles collide within a body. A spoon sitting in a hot beverage conducts heat, making its handle warm to touch. Convection is heat transfer due to bulk movement of molecules in fluids like liquids and gases. When the fluid expands, it creates a convection current as its temperature rises. This explains why warmer air rises and colder air falls. Radiation is the emission of energy as electromagnetic waves or as moving subatomic particles; it heats anything solid it travels through that soaks up its energy. Keeping something warm involves stopping the transfer of heat from one object to another. This is how insulation works.
Sciencing Video Vault
How Styrofoam Insulates
Styrofoam is made mostly of air, meaning it is a poor conductor of heat, but an excellent convector. It traps the air in small pockets, blocking the flow of heat energy. This reduces both conduction and convection and makes Styrofoam a good insulator. On the other hand, conductors such as metal are poor insulators because energy flows through them. Glass and air are other examples of good insulators. Styrofoam is placed in wall cavities to keep the inside of buildings warm. It traps air and reduces the transfer of heat energy, keeping heat inside the building.