2.3 Commenting HTML

As with all computer code, it is important to ensure your HTML is well commented. Whilst simple pages can be self-explanatory, web pages have a tendency to grow in an organic fashion rather than remaining well-structured documents and this can lead to confusing source code. Not only that, but you may forget what certain HTML tags are and do, or why you used them instead of others.

Anything enclosed between <!-- and --> is treated as a comment, and will not be displayed. Notice that unlike almost every other HTML mark the entire comment goes inside the angled brackets.

2.4 Meta-Data

In the computing world "meta-data" is the term used to describe not the user's data itself, but the data about that data. For example if you create a new file on your computer, the computer will store meta-data to describe where that file is on the system (e.g. on the hard disk), who created it and when, who has permission to read it and so on.

In HTML meta-data is used for the same sort of purposes. You can tell the browser who wrote the page and when, what the general purpose of the page is, and much more. It can also help search engines such as Google find your page and index it properly, and commercial companies often worry quite a lot about what meta-data should go in their documents.

All meta-data is defined within a <meta> tag, which goes inside the head section of the document. Since the meta-data itself will be interpreted by other programs, the data is not defined within the HTML specification; instead, the meta-variable and value is given by a name and content pair, e.g:

<title> Phil Hasnip's Home Page</title>
<meta name="author" content="Phil Hasnip">
<meta name="keywords" lang="en" content="Foolproof plan to take over the world">

Exercise 2

Add some meta-data to your page to describe who wrote it, and what it contains.

Previous page Next page