It is generally defined as the way a speaker uses language differently in different circumstances. Think about the words you choose, your tone of voice, even your body language. You probably behave very differently chatting with a friend than you would at a formal dinner party or during a job interview.
These variations in formality, also called stylistic variation, are known as *Registers* in linguistics. *