The Basic HTML5 Page

Before we get to Canvas, we need to talk a bit about the HTML5 standards that we will be using to create our web pages.

HTML is the standard language used to construct pages on the World Wide Web. We will not spend much time on HTML, but it does form the basis of <canvas>, so we cannot skip it entirely.

A basic HTML page is divided into sections, commonly <head> and <body>. The new HTML5 specification adds a few new sections, such as <nav>, <article>, <header>, and <footer>.

The <head> tag usually contains information that will be used by the HTML <body> tags to create the HTML page. It is a standard convention to put JavaScript functions in the <head>, as you will see later when we discuss the <canvas> tag. There might be reasons to put some JavaScript in the <body>, but we will make every attempt to keep things simple by having all JavaScript in the <head>.

Basic HTML for a page might look like Example 1-1.

Example 1-1. A basic HTML page

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CH1EX1: Basic Hello World HTML Page</title>
</head>
<body>
Hello World!
</body>
</html>

Get HTML5 Canvas, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.