Pathogenic bacteria commonly produce a bacterial capsule, a thick, mucous-like, layer of polysaccharide. The capsule cloaks antigenic proteins on the bacterial surface that would otherwise provoke an immune response and thereby lead to the destruction of the bacteria.  Capsular polysaccharides are water-soluble, commonly acidic, and have molecular weights on the order of 100,000 to 2,000,000 daltons.  They are linear and consist of regularly repeating subunits of one to six monosaccharides.  There is enormous structural diversity; nearly two hundred different polysaccharides are produced by E. coli alone.  Mixtures of capsular polysaccharides, either conjugated or native, are used as vaccines.
Bacteria and many other microbes, including fungi and algae, often secrete polysaccharides to help them adhere to surfaces and to prevent them from drying out.  Humans have developed some of these polysaccharides into useful products, including xanthan gum, dextran, welan gum, gellan gum, diutan gum and pullulan.
Most of these polysaccharides exhibit useful visco-elastic properties when dissolved in water at very low levels. This makes various liquids used in everyday life, such as some foods, lotions, cleaners, and paints, viscous when stationary, but much more free-flowing when even slight shear is applied by stirring or shaking, pouring, wiping, or brushing. This property is named pseudoplasticity or shear thinning; the study of such matters is called rheology.
Aqueous solutions of the polysaccharide alone have a curious behavior when stirred: after stirring ceases, the solution initially continues to swirl due to momentum, then slows to a standstill due to viscosity and reverses direction briefly before stopping. This recoil is due to the elastic effect of the polysaccharide chains, previously stretched in solution, returning to their relaxed state.
Cell-surface polysaccharides play diverse roles in bacterial ecology and physiology. They serve as a barrier between the cell wall and the environment, mediate host-pathogen interactions. Polysaccharides also play an important role in formation of biofilms and the structuring of complex life forms in bacteria like Myxococcus xanthus.
These polysaccharides are synthesized from nucleotide-activated precursors (called nucleotide sugars) and, in most cases, all the enzymes necessary for biosynthesis, assembly and transport of the completed polymer are encoded by genes organized in dedicated clusters within the genome of the organism. Lipopolysaccharide is one of the most important cell-surface polysaccharides, as it plays a key structural role in outer membrane integrity, as well as being an important mediator of host-pathogen interactions.
The enzymes that make the A-band (homopolymeric) and B-band (heteropolymeric) O-antigens have been identified and the metabolic pathways defined. The exopolysaccharide alginate is a linear copolymer of β-1,4-linked -mannuronic acid and -guluronic acid residues, and is responsible for the mucoid phenotype of late-stage cystic fibrosis disease. The pel and psl loci are two recently discovered gene clusters that also encode exopolysaccharides found to be important for biofilm formation. Rhamnolipid is a biosurfactant whose production is tightly regulated at the transcriptional level, but the precise role that it plays in disease is not well understood at present. Protein glycosylation, particularly of pilin and flagellin, became a focus of research by several groups from about 2007, and has been shown to be important for adhesion and invasion during bacterial infection.