|
|
|
||
|
|||
|
|
Comp25: HTML Basic TagsThe purpose of an HTML tag is to mark-up text with formatting and other instructions. There are almost one hundred tags defined in HTML, but we'll only be looking at a handful of the most common and useful ones. Tag SyntaxAn HTML tag consists of the name of the tag name surrounded by < and >. Tags almost always come in pairs: a start tag and an end tag. An ending tag is the same tag with a / in front of it. For example: This is my <b>first webpage</b>! In the above example, the words "first webpage" are surrounded by <b> tags. <b> is the tag to make text appear bold. Note that the ending tag is </b>, specifying that we no longer want to bold any more text. A tag's effects will not stop until it is ended. Consider the example we used for your first web page: <html> If you look carefully, you will see that every start tag has a matching end tag. Many of these tags are nested inside other tags to create a combination of effects. Remember the term element? The example above has four elements:
You will also notice that all tags are written in lowercase letters. While this is not a requirement today, it is a requirement in a special version of the HTML language called XHTML. Required HTML TagsThere are two tags that you must include to confirm to universally accepted standards. Those tags are <html> and <body>. <html> <body> ... ... ... </body> </html> You'll see in the example above that all content appears inside the <html> and <body> tags, and that both of those tags end at the end of the file. Standard Formatting TagsIt is recommended that you try out each of the following tags to see their effect on your web page. Remember as you test that every tag (unless otherwise specified) will have a matching ending tag. ParagraphsYou must mark paragraphs in HTML. This is simple enough: you use the <p> tag in front of the paragraph and the </p> tag where the paragraph ends. This creates a paragraph element. Your web browser will automatically insert an extra space between paragraph elements, much like you see in the paragraphs throughout this text. HeadingsTo help organize your web page into distinct areas, you should use the available Heading tags. <h1> is the largest heading and is usually used for the title of the page. <h2> is next, used for subheadings on the page. The web page you're reading now takes advantage of headings all over the place. Look up and down and you'll see the various sections that are marked by different sized headings. There are six levels of headings available (h1 through h6). As you increase the number, the text becomes smaller. Most people only use the first two or three. Here is an example of how you can use the heading tags:
In addition to making the text larger, the web browser will automatically insert some space before and after the heading elements. Line BreaksIf you want to start a new blank line, but don't want to use the <p> tag because it creates a wide space, you can use the <br> tag. It might look like this: 1234 Fifth Street<br> Note that there is no ending <br> tag. There are ways, however, to use the <p> tag without adding space after it. We'll discuss this later in a section called Styles. Horizontal RuleIf you wish to create a simple straight line across your page you can use the <HR> tag. It looks like this:
Want to make your line look better? We'll learn that when we go into Styles. Note that there is no ending <hr> tag. BoldMaking text bold is easy. Just surround the text with opening and closing <b> tags: This word has <b>emphasis</b>! ItalicUsing italics is just like bold: surround it with opening and closing <i> tags: Remember to put new terms <i>in italics</i>. Block QuoteIf you want a section of text indented, perhaps for a quotation or other purpose, you can use the <blockquote> tag before and after the text:
The code above creates three elements: the first paragraph element, the blockquote element, and the final paragraph element. Head and Title TagsThere are two special tags that we can't forget about: <head> and <title>. Recall that the <body> tag defines the body of our HTML document. Everything inside the <body> tag is what appears in the web browser page. The <head> tag contains special header information about the document such as its title, formatting notes, search engine information, who the author is, and more. Remember our example from before? Let's enhance that a bit with the <head> and <title> tag: <html> The <title> tag tells the browser what text to display in the window's title bar. It's not actually displayed in the page itself. Make the change on your computer, and look carefully to see the difference. If you add a page to your Favorites, the <title> tag also specifies what text appears as the favorite's name. The <title> tag must go inside the <head> tag, and remember <title> and <head> both need matching end tags. Creating ListsHTML provides an easy way to create a list of items. The list can either be numbered or bulleted. Try the following example in your HTML:
Our example contains two lists, each prefaced with a level one heading. The first list, our shopping list, is bulleted. The second list, the places we need to go, is numbered. We used three tags to make this happen:
Notice that each of the three tags have an ending tag. It is very important that you do not forget the ending OL or UL tags, or you will have major formatting issues. Special Symbols♥ ♠ ♣ ♦ Entities for Symbols and Greek Letters A Note About Privacy and GoogleGoogle is programmed to "crawl" the internet on a regular basis and find new web pages, adding them to its massive search database. Often, Google will "cache" a page as well, making it accessible even if the original page has been removed. For a variety of reasons, many students do not want their website to be found on Google through searching or caching. You can add the following HTML tags in the <head> section of your pages to signify that you do not want to be index or cached:
Please keep in mind that not every search engine follows these guidelines. For more information, please visit Google's Help on Removing Your Page from its Index. Additional ReadingFor more in-dept reading on this content, try the following:
|
| Copyright © 2008-09 University of the Pacific, Stockton, California. All rights reserved. |