By itself, HTML is a language with limited power. You use it to describe the static structure of your content. When the browser renders plain HTML, the content is inert and passively consumed by the viewer. With CSS, you may add a bit of life to your static content through media queries, animations, and styles that are triggered by clicking and hovering. To achieve true dynamic behavior, however, you need a scripting language.
With a scripting language, you may:
The most common scripting language of the web is JavaScript. To understand how JavaScript came to be, let's take a step back in history…
It was 1995. The web was becoming the "un-desktop," a place where organizations and individuals shared things that didn't depend on a particular operating system. The web was rising fast and so was Netscape, the most popular browser of the time. Microsoft feared missing out on the new opportunities brought on by the web and was triggered into developing Internet Explorer. Meanwhile, Sun Microsystems had just abandoned the world of smart appliances and decided to make Java a language for applications served out on the web. The same Java bytecode could run on any computer with a Java virtual machine, which fit nicely into the idea of the web as a neutral platform. To combat the looming Microsoft, Netscape and Sun decided to join forces.
Netscape started building a lightweight scripting language that they viewed and marketed as a companion language to Java. It was even named Mocha in its early stages of development. Its companion status was made even more explicit when it was released under the name JavaScript, a name chosen expressly for its marketing benefit. The language actually has very little in common with Java apart from its semi-colons and braces. JavaScript has more in common with functional languages, which tend to be organized around functions instead of objects.
JavaScript was originally meant to be both a client language and a server language. Netscape used it in their Live Server product, which allowed web developers to write scripts to assemble served content. When Live Server failed, in part because Microsoft introduced their own server-side scripting language called Active Server Pages (ASP), JavaScript took on an identity as a client language, run by the web browser on the viewer's computer. This role limited its power and made it an object of scorn for the first decade of its life. One could use it to manipulate the DOM and handle events, but that was about it. As the web grew, however, JavaScript gained the power to talk to servers. This meant that web developers could respond to an event by firing off a database query in the background, collecting up the results, and dynamically updating portions of the document—all without reloading the page.
Today JavaScript is one of the three core languages of the web. Many other languages compile down to it, making it the "assembly language of the web."