The Least You Need to Know about HTML and the Web
In This Chapter
- Creating HTML in text files
- Serving and browsing Web pages
- Understanding links and URLs
- Understanding basic HTML syntax
Welcome to the wonderful world of the Web and HTML. With just a little bit of knowledge, some practice, and something to say, you can either build your own little piece of cyberspace or expand on work you’ve already done.
This book is your down-and-dirty guide to putting together your first Web page, sprucing up an existing Web page, or creating complex and exciting pages that integrate intricate designs, multimedia, and scripting.
The best way to start working with HTML is to jump right in, so that’s what this chapter does: It brings you up to speed on the basics of how HTML works behind the scenes of Web pages, introducing you to HTML’s building blocks. When you’re done with this chapter, you’ll know how HTML works so you can start creating Web pages right away. Web Pages in Their Natural Habitat
Web pages can contain many kinds of content, such as text, graphics, forms, audio and video files, and interactive games.
Browse the Web for just a little while and you see a buffet of information and content displayed in many ways. Every Web site is different, but most have one thing in common: the Hypertext Markup Language (HTML).
Whatever information a Web page contains, every Web page is created in HTML (or some reasonable facsimile). HTML is the mortar that holds a Web page together; the graphics, content, and other information are the bricks.
HTML files that produce Web pages are just text documents. That’s why the Web works as well as it does. Text is the universal language of computers. Any text file that you create on a Windows computer, including an HTML file, works equally well on any other operating system.
But Web pages aren’t merely text documents. They’re made with a special, attention-deprived, sugar-loaded text called HTML. HTML is a collection of instructions that you include along with pointers to your content in a text file that specifies how your page should look and behave.
Stick with us to discover all the details you need to know about HTML!
Special instructions in HTML permit text to point (link) to something else. Such pointers are called hyperlinks. Hyperlinks are the glue that holds the World Wide Web together. In your Web browser, hyperlinks usually appear in blue and are underlined. When you click one, it takes you somewhere else.
Hypertext or not, a Web page is a text file. You can create and edit a Web page in any application that creates plain text (such as Notepad). When you’re getting started with HTML, a text editor is the best tool to use. Just break out Notepad and you’re ready to go. Some software tools have fancy options and applications to help you create Web pages, but they generate the same text files that you create with plain-text editors.
The World Wide Web comes by its name honestly. It’s quite literally a web of pages hosted on Web servers around the world,connected in millions of ways. Those connections are made by hyperlinks that connect one page to another. Without such links, the Web is just a bunch of standalone pages.
Much of the Web’s value comes from its ability to link to pages and other resources (such as images, downloadable files, and media presentations) on either the same Web site or at another site. For example, FirstGov (www. firstgov.gov) is a gateway Web site — its sole function is to provide access to other Web sites. If you aren’t sure which government agency handles firsttime loans for homebuyers, or if want to know how to arrange a tour of the Capitol, visit this site to find out.
Figure : FirstGov uses hyperlinks to help visitors find government information.
Web browsers were created specifically for the purpose of reading HTML instructions (known as markup) and displaying the resulting Web page.
Markup lives in a text file (with your content) to give orders to a browser.
You can see how the page is made up and how it is formatted by examining its underlying HTML.
Figure : This Web page incorporates multiple parts and numerous bits of markup.
This page includes an image, a heading that describes the page, a paragraph of text about red wine, and a list of common grape varietals.
However, different components of the page use different formatting:
- The heading at the top of the page is larger than the text in the paragraph.
- The items in the list have bullet points (big dots) before them.
The browser knows to display these components of the page in specific ways thanks to the HTML markup.
Listing : Sample HTML Markup
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
<h1><img src=”red_grapes.jpg” width=”75” height=”100”
alt=”Red Grapes” align=”middle” hspace=”5” />
Understanding Red Wine Varietals
<p>Although wines tend to be generically categorized as
either “white” or “red,” in reality, there is a
collection of wine varietals each with its own
distinguishing characteristics. The red category
includes a robust collection of over 20 varietals,
Any text enclosed between less-than and greater-than signs (< >) is an HTML tag (often called the markup). For example, a p within brackets (<p>...</p> tags) identifies the text about red varietals as a paragraph; the li (<li>... </li> tags) markup identifies each item in a list of varietals. That’s really all there is to it. You embed the markup in a text file, along with text for readers to view, to let the browser know how to display your Web page. Tags and content between and within the tags are collectively called elements.
The user’s piece in the Web puzzle is a Web browser. Web browsers read instructions written in HTML and use those instructions to display a Web page’s content on your screen.
You should always write your HTML with the idea that people will view the content using a Web browser. Just remember that there’s more than one kind of browser out there, and each one comes in several versions.
Usually, Web browsers request and display Web pages available via the Internet from a Web server. You can also display HTML pages you’ve saved on your own computer before making them available on a Web server on the Internet. When you’re developing your own HTML pages, you view these pages (called local pages) in your browser. You can use local pages to get a good idea of what people see after the page goes live on the Internet.
Each Web browser interprets HTML in its own way. The same HTML doesn’t look exactly the same from one browser to the next. When you work with basic HTML, variances aren’t significant, but as you integrate other elements (such as scripting and multimedia), rendering the markup can get hairy.
Some people use text-only Web browsers, such as Lynx, because either
- They’re visually impaired and can’t use a graphical display.
- They like a lean, fast Web browser that displays only text.
Your HTML pages aren’t much good if you can’t share them with the world. Web servers make that possible. A Web server is a computer that
- Connects to the Internet
- Runs Web server software
- Responds to requests from Web browsers for Web pages
Almost any computer can be a Web server, including your home computer. But Web servers generally are computers dedicated to the task. You don’t need to be an Internet or computer guru to publish your Web pages, but you must find a Web server to serve your pages:
- If you’re building pages for a company Web site, your IT department may have a Web server. (Ask your IT guru for the information.)
- If you’re starting a new site, you need a host for your pages.
Finding an inexpensive host is easy.