The goal of this lesson is to show you how to create an extremely basic HTML web page. The code we use will generate the page, and output the text, "Hello, world." End Result.
Note that in order to create an HTML page, you will first need to create a new HTML document. Any text editor (not word processor, though) will work. Just create a new document, and instead of saving it as a .txt file, save it as either .htm or .html - these two extensions are recognized by browsers as HTML documents. Which extension you choose is up to you; just be consistent. I will be using .html.
The first part of any HTML document is the DOCTYPE
. This is a statement that tells the browser which version of HTML you are using. The DOCTYPE
used to be quite complex, but with the release of HTML5, it has been reduced down to a single, short line, which you can see to the right.
The next line of code is the opening html tag. This is what actually begins the document. Its respective closing tag will also be the last line of the file. Since everything inside the document is inside the html
element, I do not indent after the <html>
tag.
<!DOCTYPE html> <html lang="en">
</html>