A basic HTML document
This sample document is targeted for the upcoming HTML5, but works in current browsers as well.
<!DOCTYPE html>
<html>
<head>
<title>My First Webpage</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p>Hi, I'm your first paragraph. It's nice to meet you!</p>
</body>
</html>
Despite this being one of the shortest HTML documents you'll ever see, there are lots of things to talk about in it! The first thing you need to understand is that anything in angle brackets <like this> is an HTML tag. If it has a / (forward slash) at the beginning </like this> it's a closing tag; otherwise it's an opening tag. In general, every opening tag must have a matching closing tag, and such a pair of tags is an HTML element. We'll talk about that again later.
Required tags
Most of the tags in the sample document must be included in every document.
<!DOCTYPE html>- This is a legacy of older HTML versions. You don't need to understand it; just put it at the top of all your pages.<html>- This element wraps the entire document, and it must for the document to be valid HTML.<head>- This contains information about the page (and often secondary resources that enhance it), but none of the actual page itself.<title>- In visual browsers, this is displayed at the top of the window in the "title bar," and on the page's tab.<body>- Here's where the actual content goes, what all the rest of this stuff is about.
Optional tags
<meta>- This informs the browser about some aspect of how a page should be handled.[1] In this case, it identifies the proper media type and character encoding for the page. You don't need to understand this tag until much later; the stuff in it doesn't need to be changed unless you know what it's for.<p>- Well, that's a bit anti-climactic. We did all that work just to display two sentences. This element indicates that the text within it is a paragraph.
References
- ↑ A Dictionary of HTML META Tags (Don't use frames, kids!)