A cell wall is an outer layer surrounding certain cells that is outside of the cell membrane. All cells have cell membranes, but generally only plants, fungi, algae, most bacteria, and archaea have cells with cell walls. The cell wall provides strength and structural support to the cell, and can control to some extent what types and concentrations of molecules enter and leave the cell. The materials that make up the cell wall differ depending on the type of organism. The cell wall has evolved many different times among different groups of organisms.
The cell wall has a few different functions. It is flexible, but provides strength to the cell, which helps protect the cell against physical damage. It also gives the cell its shape and allows the organism to maintain a certain shape overall. The cell wall can also provide protection from pathogens such as bacteria that are trying to invade the cell. The structure of the cell wall allows many small molecules to pass through it, but not larger molecules that could harm the cell.