All web pages are written initially in HTML, but this code is only text to begin with. The browser then takes this HTML code, together with any associated CSS, and uses it to generate the visible content of the page.
As the browser loads and implements the HTML, it also creates an internal representation of the document for JavaScript. This is called the Document Object Model, or DOM to its friends. We can use the DOM to manipulate various parts of the web page in JavaScript.