The cell envelope comprises the inner cell membrane and the cell wall of a bacterium, if present, plus a bacterial outer membrane (i.e. in gram-negative bacteria).
Most bacterial cell envelopes fall into two major categories: a gram-positive type and a gram-negative type. These are the envelopes typically found in bacteria staining during a Gram stain. Regardless of its Gram status, a bacterium might have an exterior polysaccharide-containing capsule for further protection of the cell envelope, and is known as a polysaccharide encapsulated bacterium.
As in other organisms, the bacterial cell wall provides structural integrity to the cell. In prokaryotes, the primary function of the cell wall is to protect the cell from internal turgor pressure caused by the much higher concentrations of proteins and other molecules inside the cell compared to its external environment. The bacterial cell wall differs from that of all other organisms by the presence of peptidoglycan (poly-N-acetylglucosamine and N-acetylmuramic acid), which is located immediately outside of the cytoplasmic membrane. Peptidoglycan is responsible for the rigidity of the bacterial cell wall and for the determination of cell shape. It is relatively porous and is not considered to be a permeability barrier for small substrates. While all bacterial cell walls (with a few exceptions e.g. intracellular parasites such as Mycoplasma) contain peptidoglycan, not all cell walls have the same overall structures. This is notably expressed through the classification into gram positive and gram negative bacteria.