Syntax vs Semantics
Question
What is the difference between syntax and semantics in programming?
Hint
Syntax errors vs logic errors — what is the difference?
Explanation
Syntax is the grammar/structure of the code — whether the brackets match, semicolons are correct, etc. A syntax error means the code cannot be parsed. Semantics is the meaning/behavior — what the code actually does when run. A semantic error (logic error) means the code runs but does the wrong thing. Syntax is about form; semantics is about function.
Related Resources
Related Lessons
- How Programs Work
Learn how programs work.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.