Syntax is the set of rules governing how code must be written to work properly, similar to grammar rules in written language. Just as a sentence needs correct word order to make sense, programming languages need correct syntax to function. For example, missing a single bracket or semicolon in code can prevent an entire website feature from working. Proper syntax keeps code error-free and readable.
See also: Code snippet, Hypertext Markup Language (HTML), CSS