The mucus that your body secretes is there to protect you; to prevent particles that can hurt your body from getting inside. But why does it come out of you in a variety of colors?
* What Is Mucus Anyway? *
Mucus is secreted by all mucous membranes, slime-covered tissue lining the openings between the body and the outside environment. Mucus in the respiratory tract traps dirt, dust, pollen, bacteria, viruses and any number of other tiny things that we breathe in. Particles that get stuck in mucus are prevented from getting onto the lungs where they could cause irritation of infection. Boogers are made from mucus secreted by the mucous membranes of the nasal cavity.
* What Is Phlegm? *
Phlegm is the mucus secreted by the membranes of the respiratory tract. Phlegm becomes thick when it starts to dry out, and these thick globs of mucus irritate our respiratory system, which expels the phlegm when we cough.
* Why Do Boogers and Phlegm Come in Different Colors? *
The mucus that makes up nasal and respiratory secretions is clear, colorless. But we know that boogers and coughed up phlegm (sputum) can come out of us in a spectrum of colors. The color depends on what is trapped in the mucus.
If you have spent time in a dusty dirty location, your sputum and boogers will look dirty and brown. The color of mucous can also be affected by the presence of white blood cells and the microbes that these cells are trying to eliminate. White blood cells can make pus and snot look creamy white. White blood cells are present in mucus when they are there trying to fight off a bacterial or viral infection.
The bacteria that our white blood cells are trying to fight off come in a variety of colors; some are clear; some are yellow, like Staphylococcus aureus (commonly called golden staph). Other bactera that can infect our nasal cavity and respiratory tract are blue, like the species of Pseudomonas. These colors are not visible unless there are many, many bacteria present, such as when you have an infection. When a number of different colors of bacteria are present, that mixture can sometimes result other colors, like green.
* Sources
Bauman, R. (2004) Microbiology. Benjamin Cummings.
Park Talero, K. (2008) Foundations in Micobiology. McGraw Hill.