Chapter 17. HTML: building web pages
This chapter covers
- Using HTML to display static content
- Tags, elements, and attributes
- Common HTML elements
- Manipulating web page content with JavaScript
- Switching to HTML-based views in The Crypt
JavaScript is associated with adding interactivity to web pages: reacting to users clicking buttons and selecting from drop-down menus, for example, and updating parts of a page with new content. Having learned the fundamentals of the language, you’re almost ready to take that step to interactivity and dynamic content. Your focus is still on JavaScript, but you need to learn enough HTML to see how JavaScript can be used to create and manipulate the content of a web page. JS Bin still has you covered while you learn; you can add HTML and view the resulting web page in the Output panel. In chapter 21 you’ll see how to move on from the JS Bin sandbox and organize your own HTML, CSS, and JavaScript files.
You’ve spent a lot of time building The Crypt in a modular fashion. That work pays off in this chapter when you see how easy it is to switch from displaying output on the console to displaying it on a web page. It will just take a few lines of code—it’s almost magical.
You want to build a movie reviews web page, My Movie Ratings, that displays information about your favorite movies and lets you rate them (figure 17.1). To build the page you use three languages: