Creating a minimal web page
We are now ready to put together our first complete web page, which will allow us to have working examples and exercises.
Don't be concerned if you don't have a deep understanding of the explanations in this step. The purpose of the step is to tell you that there is certain information that you need to add to each page. The reasons are somewhat technical and a distraction from the main point of the course, so we'll keep the discussion fairly short.
In addition to having a language attribute to specify the human language used, we also need to specify the encoding to be used by the computer. This can be accomplished by adding a metadata element (tag nameThe characters used in a tag for a particular element. meta
), which is an empty elementAn element specified using a single tag., to the very beginning of the head elementAn element that gives information about the page., and adding a character encoding declaration using the attribute charset
. You don't need to be an expert on encodings - it is enough to know that it is safe to provide utf-8
as the valueSpecific information for an attribute. of the attribute, representing the common encoding UTF-8. (Listing UTF-8 explicitly, even if it is almost always the standard, helps avoid security problems that might arise from browsers having to guess the encoding.)
Now all that needs to be added is the document type declaration (<!DOCTYPE html>
) to show that the document is written in HTML. This should be the very first line in every document you write. Don't be surprised if you see other doctypes in documents you happen upon. There exist old versions of HTML and other languages that we will not be discussing.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
</body>
</html>
We will use this as a template for future pages that we create.