Some cells, particularly eukaryotes (cells with a nucleus and specialized organelles) can contain many membrane structures, not all of which function in exactly the same way. The membranes of bacteria, archaea and eukaryotes also differ slightly in their exact chemical composition and structure. However, all cell membranes generally function according to the same "ideas" - they define and separate the cell from the rest of its environment, and govern what stays inside, what stays outside, and what is allowed to travel across the membrane.
The membrane is said to be "semi-permeable", or selectively permeable, because it can control what materials pass through it, such as nutrients and waste. While some texts and research support the idea of materials passing directly through the membrane, in reality this is too slow and inefficient to be the primary way that a cell regulates transport. Instead, the majority of transport will take place through specialized proteins that are embedded in the membrane like doors.
The majority of the membrane is composed of phospholipids, which are a form of lipid molecule, not terribly different from a triglyceride. Whereas a triglyceride is composed of a glycerol head with three fatty acid tails, the phospholipid is composed of a glycerol head and two fatty acid tails, with a phosphate group and one of several polar group attached to the glycerol in place of the third fatty acid. This renders the "head" of the molecule polar, and the "tails" nonpolar, giving it unique structural properties that help it to maintain its integrity and regulating properties in a watery environment.