What is the difference between HTML and JavaScript?

HTML is used to define the structure and the look of the website, while JavaScript is used to add logic to it.

HTML is responsible for the initial, static content of the website, such as:

  • Render a form with 3 text fields
  • Draw a button over there

While JavaScript is responsible for the dynamic content and behaviour, such as:

  • Change the color of this text field to red when it becomes empty
  • Show a popup when this button is pressed