HTML (Hypertext Markup Language) is the lingo of the internet. It is the medium for web designers to essentially explain to web browsers how to present information to users of the Internet. Using a reference to the former predominant information medium, newspapers, you can think of HTML in the context of a newspaper editor determining the typesetting and layout for an upcoming circulation. The design staff would spell out page formats for various parts of the newspaper by determining fonts, positions, image locations, section layouts and other details. The delivered product would be the result of the determination by the designers to use a size 50, Times New Roman font for the newspaper’s title, to include certain pictures and captions associated with stories and headlines, and to organize other aspects of the newspaper’s layout according to a model.
HTML works similarly. The vocabulary understood by browsers includes markup tags such as <b> to bold text, <u> to underline text, <p> to create a new paragraph, and <ul>/<li> to create lists. HTML obviously has much more capability than a newspaper. The ability to quickly move between pages by following web links is a major advantage that web pages and the internet in general offer as an information medium. Anyone who’s used the internet to check email, make a payment, or look up an address or phone number knows that HTML and related web technologies facilitate significant interaction between the user and the information supply.
A Simple Example
This exercise will give you a basic introduction to how HTML works. On your computer open the Notepad program by going to Start Menu->All Programs->Accessories->Notepad. When the Notepad editor comes up, type (or paste) the following:
<title>My first web page</title>
<h2>My First Web Page</h2>
<p>This text makes up the first paragraph. You can’t see the paragraph tag itself, but you can tell that this section of text is set off from the next section of text by a paragraph tag. The browser doesn’t show the tags themselves. Instead, it uses the tags as instructions on how to present the information.</p>
<p>This is another paragraph. By default the text in this paragraph is separated from the previous paragraph by a line of white space, so that it appears double-spaced, similar to how two paragraphs would be separated in a typical document.</p>
<p>Enter text here: <input type=”text” width=”50″ />
<p>What’s your favorite food?
<option>Mac and Cheese</option>
Now save the file using the name “html-example.html”. After you save the file, open a web browser (Internet Explorer and Firefox are the two most popular), then open the file you just created by using the File->Open… or File->Open File… command in the browser. When you open the html-example.html file in your browser, you should see something like this:
So how did all those tags turn into what you see in your browser? I will explain.
HTML segments are typically opened by a start tag and closed by an end tag. The first tag you’ll see in an HTML page is the <html> tag. At the end of the page, you’ll see a tag like this </html>. The ‘/’ included in the end tag tells the browser, “This is where the html tag ends.” Although it isn’t always necessary to close all HTML tags that have been opened, it’s best to explicitly provide a closing HTML tag for each tag opened. HTML tags can be, and very often are, nested inside of other tags. For example, every HTML tag on a page is nested inside of the <HTML></HTML> tag.
There are two main tags that divide an HTML document into its major sections. After the <html> tag is the <head> tag. The information enclosed in the <head> tag normally deals with describing what the HTML page is about. In our example, you see a <title> tag enclosed within the <head></head> section. You notice that the text inside the <title> tag is displayed at the top of the browser, but not actually in the main section of the web page itself.
The <body> tag is the section that contains the functional content of the web page. Most of the interaction between a web page and its users occurs in the <body> section of an HTML document.
Common HTML Tags
Following our example above, the paragraph (<p>) tags tell the browser to set off the text contained within them as separate paragraphs. You’ll notice that there is a line of white space between the first and second paragraphs on the page. That’s because the browser is following the formatting standard for <p> tags.
The last two items included in our example HTML document are interesting. To allow for interaction between the user and the web page, various kinds of user input tags exist as part of the web markup language. The first one in our example, <input type=”text” width=”50”>, allows the user to enter text that can be sent to the web server and processed. The ‘type’ attribute of the <input> tag tells the browser which kind of input box to create. The ‘width’ attribute of the <input> tag tells the browser how many characters wide the input box should be.
The last item in our HTML example, a drop-down box, is created using the <select> tag and associated <option> tags, which are used to create a list of choices within the <select> box.
There are dozens of HTML tags that can be used on a web page. To find a comprehensive list of the HTML tags understood by browsers, you can visit www.w3.org or do a web search for “html tags”.