Originally posted on Grammar Monkeys on June 4, 2012.
Strictly speaking, grammar is the unique patterns of a language, the system of how speakers can put together words and sentences. Grammar encompasses morphology (how to form words), syntax (how to form sentences) and semantics (what words and sentences mean). This is what linguists talk about when they talk about grammar.
The following areas are not grammar in the strict definition, but fall under the larger definition of grammar as “rules and principles of language”: punctuation, phonology (the sound system), orthoepy (correct pronunciation), orthography (correct spelling) and lexicon (vocabulary and usage). These (plus morphology, syntax and semantics) are what most people talk about when they talk about grammar.
The second definition of grammar is pretty broad, but there are language-related rules that fall outside of grammar. Many of these are style rules: whether to put the period inside or outside of quotation marks, whether e-mail is hyphenated or a single word, and so on. Style rules are set to ensure consistency in writing, so readers aren’t distracted by small differences. (And yes, readers do notice when things aren’t consistent.)