|
HTML Basics What Is a Web Page? A web page is not a special kind of file. In fact, a web page is the plainest, most ordinary kind a file: a plain text file. Any word processor or text editor can make a web page. A web page usually has a file name with the suffix (extension) of ".html" or ".htm" (either is OK, but ".html" is more common). When you create a web page, it starts out as a text file. When you save it, it could be called "webpage.txt". You have to make sure the suffix is changed to ".html" so that it will work as a web page. How Does a Web Page Work? A web page contains special HTML commands (also called "HTML Tags"). An HTML tag tells a browser what to do.
HTML tags are easy to make. Just put any HTML tag inside angle brackets: <html>
When the browser sees the brackets, it knows that what is inside is a command.
What Do HTML Tags Do? HTML tags tell the browser what to do. The <title> tag tells the browser what name to put into the title bar. The <br> tag tells the browser to go down one line. The <blockquote> tag tells the browser to indent by 1/2 inch. The <img> tag tells the browser to find a picture file and put it on the web page in a certain location. The <a> tag tells the browser to make a link to another page. There are many, many HTML tags, but you only need to remember a few dozen to make a good web page. How Do I Type an HTML Tag? There are two kinds of tags:
For example, let's say that you want to make some bold text. The command is simple: <b> However, bold text always begins at one point and ends at another point. So there must be an ending tag, which is the same as the beginning tag, except it has a back-slash before the command--for example: </b> If you forget the ending tag, then the change you made will continue until the end of the web page, and could cause other problems. Therefore, in a web page, if you type:
It will appear like this in a browser:
Live HTML Exercise Test this out! In the space below, you will see two areas: a pink area at the top, and a blank area below it. When you type in the pink area, the web page output will appear below. In the PINK area, click BEFORE the last two words ("play with") and type in the command "<b>". Notice that when you do this, all the text after the command turns bold. That's because you gave a starting command but did not tell the browser to finish. So, AFTER the words "play with," type the ending command for bold, which is "</b>". Once you finish, you will see the rest of the text go normal again, and just the words inside the <b> and </b> commands will be bold.
There are many more commands. Here are a few; you may want to try them in the live test box above:
Note that the last one, "<hr>", has no end command--none is needed, because the item (a line) does not "start" and "end" between certain locations in the text. It is in "one place," and so there is just the command to place the line. Some HTML commands are like this. Attributes Many HTML tags have more features which can be activated. For example, there is a command called <font>. The FONT command by itself does nothing. However, by adding extra command information, you can use the FONT command to change the color and size of certain text. However, you must say what color, and what size. In order to give this information, you need to use Attributes. An attribute is a secondary command which comes after the main command. The attribute introduces special information ("values") about colors, sizes, locations, addresses and so forth. The value is usually in quotes; though the attribute can work without quotes, using quotes is considered good style. The attributes are separated by spaces; there are no spaces inside an attribute. Therefore, a command with attributes looks like this: <command attribute="value" attribute="value"> </command> A specific example would be: <font size="+2" color="red"> </font>
Important: Attributes and their information ONLY appear in the BEGINNING tags, and NEVER in the ENDING tags. This is shown in the examples above. The ending tag with the back-slash must ONLY have the main command only. Some commands with attributes:
A few notes:
Live HTML Exercise (Attributes) Try out some of the attributes above in the live text window below. If they don't appear correctly, check your spelling and HTML syntax carefully for errors. Even a small error can "break" the page!
Strange Things When you are writing HTML, there are some special concepts you must remember. They will seem strange to you because they are different from your usual experiences with computers. For example, writing a web page is NOT like writing something in a word processor. Word processors have many tricks that help you type more easily. For example, in a word processor, if you want to make a word bold, you just select the word and then click on the BOLD button in the toolbar. In HTML, you must use the commands in the angle brackets to give the "B" command to make the word bold. Another example is making new lines (called "line breaks"). In a word processor, you just hit the ENTER key, and you have a new line. This does not work in HTML. You can hit ENTER a lot of times, and you will see the new lines in your text editor, but the browser will not see them! For example, in an HTML file, if you type this:
That will appear in the browser like this:
This is because the browser does not see ENTER. You could tupe the ENTER key 100 times, but the browser will not show any of them when it displays the web page. Therefore, you must type the <BR> command:
That will appear in the browser like this:
Notice that when I was typing the HTML, I did not bother to use the ENTER key. I could if I wanted to, and many people use it just so the HTML page appear more organized. But as you can see abover, it is not necessary for the web page to look nice in the browser. If you want to make a new paragraph, you can use the <p> command. The BR tag only goes down to the next line, single-spaced. The P goes down two lines, like a double-space. See the difference:
That will appear in the browser like this:
It is similar for spaces (the SPACE bar on the keyboard). A web browser will only see one space at a time. Make two spaces in a row, and the browser will show only one. If you type twenty spaces in a row, the browser will still only show one on the web page. Therefore, when you type this:
That will appear in the browser like this:
It is possible to put more than one space together in a row, but you must use a special character. Special characters always begin with an ampersand (&) and end with a semicolon (;). The special character for a space is which stands for "non-breaking space." There are many such special characters. If this is all too confusing, you can always use the <pre> command, which is for pre-formatted text. Any text within the <pre> and </pre> tags will appear exactly as you typed it--all ENTERs and SPACEs will be visible. (However, all the angle-bracketed HTML commands will be visible too! So don't use the PRE command except in special cases.)
Now You Know Now you know some of the basic points of the HTML document. You are ready to start studying the structure of a web page.
|