OK, lets get straight into it. Here, you will learn just how easy it is to create a web page. In fact, by the time you've finished with this web page, you will have created your own web page!
When you create a web page you will usually do something like this:
- Create an HTML file
- Type some HTML code
- View the result in your browser
- Repeat the last 2 steps (if necessary)
Creating a Webpage
OK, let's walk through the above steps in more detail.-
Create an HTML file
An HTML file is simply a text file saved with an .html or .htm extension (i.e. as opposed to a .txt extension).- Open up your computer's normal plain text editor (this will probably be Notepad if you're using Windows or TextEdit if you're using a Mac). You could use a specialized HTML editor such as DreamWeaver or FrontPage if you prefer.
- Create a new file (if one wasn't already created)
- Save the file as html_tutorial_example.html
-
Type some HTML code
Type the following code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>HTML Tutorial Example</title>
</head>
<body>
<p>Less than 5 minutes into this HTML tutorial and
I've already created my first homepage!</p>
</body>
</html> -
View the result in your browser
Either...- Navigate to your file then double click on it
- Open up your computer's web browser (for example, Internet Explorer, Firefox, Netscape etc).
- Select File > Open, then click "Browse". A dialogue box will appear prompting you to navigate to the file. Navigate to the file, then select "Open".
-
Repeat the last 2 steps until you're satisfied with the result
It's unrealistic to expect that you will always get it right the first time around. Don't worry - that's OK! Just try again and again - until you get it right.
Explanation of code
OK, before we get too carried away, I'll explain what that code was all about.We just coded a bunch of HTML tags. These tags tell the browser what to display and where. You may have noticed that for every "opening" tag there was also a "closing" tag, and that the content we wanted to display appeared in between. Most HTML tags have an opening and closing tag.
All HTML documents should at least contain all of the tags we've just coded and in that order.
The next lesson goes into a bit more detail about HTML tags.
HTML elements are the fundamentals of HTML. HTML documents are simply a text file made up of HTML elements. These elements are defined using HTML tags. HTML tags tell your browser which elements to present and how to present them. Where the element appears is determined by the order in which the tags appear.
HTML consists of almost 100 tags. Don't let that put you off though - you will probably find that most of the time, you only use a handful of tags on your web pages. Having said that, I highly recommend learning all HTML tags eventually - but we'll get to that later.
OK, lets look more closely at the example that we created in the previous lesson.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>HTML Tutorial Example</title>
</head>
<body>
<p>Less than 5 minutes into this HTML tutorial and
I've already created my first homepage!</p>
</body>
</html>
- The <!DOCTYPE... > element tells the browser which version of HTML the document is using.
- The <html> element can be thought of as a container that all other tags sit inside (except for the !DOCTYPE tag).
- The <head> tag contains information that is not normally viewable within your browser (such as meta tags, JavaScript and CSS), although the <title> tag is an exception to this. The content of the
<title>tag is displayed in the browser's title bar (right at the very top of the browser). - The <body> tag is the main area for your content. This is where most of your code (and viewable elements) will go.
- The <p> tag declares a paragraph. This contains the body text.
Closing your tags
As mentioned in a previous lesson, you'll notice that all of these tags have opening and closing tags, and that the content of the tag is placed in between them. There are a few exceptions to this rule.You'll also notice that the closing tag is slightly different to the opening tag - the closing tag contains a forward slash (
/) after the <. This tells the browser that this tag closes the previous one.UPPERCASE or lowercase?
Although most browsers will display your page regardless of the case you use, you should always code in lowercase. This helps keep your code XML compliant (but that's another topic).| Therefore... | Good: | <head> |
| Bad: | <HEAD> |