Grammar is a field of linguistics that involves all the various things that make up the rules of language. Subfields of linguistics that are considered a part of this field include syntax, phonetics, morphology, and semantics. Grammar is also used as a term to refer to the prescriptive rules of a given language, which may change over time or be open to debate.
This topic is often divided into two common broad categories: descriptive and prescriptive. Both views are in wide use, although in general, linguists tend towards a descriptive approach to grammar, while people teaching a specific language — such as English — might tend towards a more prescriptive approach. Usually, there is a bit of give and take in any approach, with a prescriptivist being at least somewhat descriptive, and a descriptivist having some prescriptivist tendencies.
A descriptive approach tries to look at the grammar of any spoken language or dialect as it actually exists, judging whether a sentence is grammatical or not based on the rules of the speech group in which it is spoken, rather than another, arbitrary set of rules. For example, in many speech communities, a sentence such as "He done got thrown off the horse," would be entirely grammatical, and an entire set of language rules can be deduced that explain why that formation is grammatical. In another speech community, however, this sentence might be considered ungrammatical, while a version such as "Him isa throwned offa horse," would be the grammatical version. In yet another speech community, both would be considered ungrammatical, with only a version such as "He was thrown off of the horse," being considered acceptable.
A prescriptive grammar looks at the norms of speech as given by authoritative sources, such as an upper-class or academic subculture, and creates strict rules by which all speech within that language must abide to be considered grammatical. Few linguists take a prescriptive approach in the modern age, preferring to describe language as it exists in a given speech community. Many teachers, grammar mavens, and pedagogues in general still have a prescriptive approach, however, holding to standardized rules as being the only proper way to speak.
In some cases, a prescriptive approach is also used in teaching a language to non-native speakers. When teaching English, for example, it can be useful to employ a "standard" form of English as a baseline to teach from, to help reduce confusion among students. Once the language has been acquired, of course, a less-prescriptive approach will necessarily take over, as the non-native speaker learns regional rules and new dialects that may not conform to the version that he or she originally learned.