What is the difference between syntax, semantics and pragmatics?
Three levels of meaning: syntax is structure, semantics is literal meaning, and pragmatics is what is actually communicated in context. A sentence can succeed at one and fail at another.
Syntax. The rules governing how words combine into phrases and sentences. Whether a sentence is well formed, independent of whether it makes sense.
Chomsky's famous example — colourless green ideas sleep furiously — is syntactically perfect and semantically nonsensical, which is exactly the point: the two levels are separable. Conversely ideas green furiously colourless sleep is neither.
Semantics. Literal, conventional meaning — what words and sentences mean independent of who says them and why. It covers word meaning, relationships between meanings, ambiguity, and whether one sentence entails another.
Ambiguity comes in two kinds, and the distinction is a neat demonstration of the levels: I saw her duck is lexically ambiguous (the animal, or the action) and structurally ambiguous too.
Pragmatics. What is meant in context, beyond what is said. This is where most everyday communication actually happens.
"Can you pass the salt?" is semantically a question about ability. Pragmatically it is a request, and answering "yes" without moving is a joke precisely because the two diverge.
Implicature — Grice's term for what is conveyed without being stated. "Some students passed" implies not all did, though it does not literally say so.
Grice's maxims describe the cooperative assumptions behind conversation — be truthful, informative, relevant and clear — and much of what we communicate works by deliberately flouting them. Irony, understatement and sarcasm all depend on the listener noticing a maxim has been broken on purpose.
Deixis — words like here, now, this, you — have no fixed reference and depend entirely on context, which is why a note saying "back in ten minutes" is useless without knowing when it was written.
Speech acts: some utterances do things rather than describe them — "I promise", "I apologise", "I name this ship".
Why it matters practically: most miscommunication is pragmatic, not semantic.