Creating HTML Documents
Formatting HTML documents depends on markup codes called tags. Tags define the structure of the document and include an element name enclosed by brackets, such as <H1>, which indicates the start of a Level One heading. HTML is not case-sensitive, so <h1> and <H1> both mean the same thing.
Most tags are used in pairs. A tag called the begin tag tells the browser a document element is beginning, and another tag called the end tag tells the browser an element is ending. The only difference between the two is that the end tag has a forward slash before the element name. For example, the begin heading tag <H1> is paired with the end heading tag </H1>. The initial <H1> tag tells the browser a Level One heading is starting, and the end tag </H1> tells the browser the heading is ending
In HTML, you can also define a special character to display. Special characters are described by an element name preceded by an ampersand and ending with a semicolon, such as & for the ampersand symbol, or for the space character. When a browser sees a special character, it interprets the special character and displays the corresponding symbol, if possible.
Every HTML document should begin with the markup tag <HTML> and end with the markup tag </HTML>. The begin tag <HTML> tells the browser the document is an HTML-formatted document and marks the beginning of the document. The end tag </HTML> marks the end of the document and is always the last item in any HTML document.
Although you might find HTML documents on the Web that don't include the begin and end <HTML> tags, it's poor design style not to use these tags. HTML isn't the only markup language in use on the Web; without identifying your document as HTML, you might confuse the reader's browser.
Every HTML document should also have a header and a body. The header immediately follows the first <HTML> tag and is used to specify key aspects of the document, such as its title. The beginning of the header is specified with the begin header tag <HEAD>, and the end of the header is specified with the end tag </HEAD>.
Following the header is the main section of the document, called the body, which contains the text and objects you want to display in the reader's browser. Like the header, the body has the begin tag <BODY> and end tag </BODY>.
Required
HTML Tags
Please NOTE: These items
must appear in every page you create in this order!
<HTML> ... </HTML> The open tag should be the first thing on your document and the closed tag should be the last thing on your document. These tell the browser that this document, and everything in between, is an HTML document.
<HEAD> ... </HEAD> This is used for those items being placed at the top of the document.
<TITLE> ... </TITLE> This tag places your title information, not on the top of your page, but at the very top of the screen. The title tags always go between the head tags.
<BODY>. ... </BODY> Basically, everything goes between these tags except the title tags.
So, if you are building your first HTML document, at this point, the tags should look like this:
<HTML>
<HEAD>
<TITLE>My first
web page.</TITLE>
</HEAD>
<BODY>
HTML code must be written here.
</BODY>
</HTML>
Headings
One of the ways to set off your documents is to have different headings. HTML code has these pre-written for you with the use of heading tags. There are six levels of headers and must be opened and closed. Each level is numbered. Use <H1>..</H1> for heading 1. Use <H2>...</H2>, etc. Here is an example of the different levels:
This is a level 1 heading.
This is a level 2 heading.
This is a level 3 heading.
This is a level 4 heading.
This is a level 5 heading.
This is a level 6 heading.
Lists
For unordered lists, you can use these values with the unordered list tag:
<UL
TYPE=CIRCLE> Use an
open circle for the bullet
<UL TYPE=SQUARE> Use a square for the bullet
<UL TYPE=DISC> Use a solid circle for the bullet, which is the
default
For unordered lists
<OL TYPE=A> Use capital letters for the ordered list elements
<OL TYPE=a> Use lowercase letters for the ordered list elements
<OL TYPE=I> Use Roman numerals for the ordered list elements
<OL TYPE=i> Use lowercase Roman numerals for the ordered list elements
<OL TYPE=1> Use numerals for the ordered list elements, which is the default
To add an item to the list, you can use the <LI> tag.
Here is an example of ordered lists.
HTML
CODE
<OL TYPE=1>
<LI> Java
<LI> C++
<LI> Pascal
<LI> Fortran
</OL>
PREVIEW
1. Java
2. C++
3. Pascal
4. Fortran
Paragraphs
In HTML, the way to visually break up the document into paragraphs is to use the paragraph tag <P>. When a browser sees the paragraph tag, it ends the current line and inserts a blank space before inserting the text or object following the paragraph tag. If you're using a word processor or text editor to create your Web document, keep in mind that browsers reduce all ASCII text formatting-including multiple spaces, tabs, or blank lines-to a single space.
You can create paragraphs as follows:
<P> Insert the paragraph text here. </P>
Links
With the anchor tag <A HREF=Web Address> </A>, you can create a link to any other web page. The basic format of a hypertext link is this:
<A HREF="Web Address"> Text or Object reader sees and can click on </A>
The opening <A> tag contains the address of the files you're linking. The address isn't visible in a document unless the mouse pointer is over the anchor. The anchor is the portion of the link that's visible when a browser displays the document; it's positioned between the begin and end anchor tags. To activate a link, you move your mouse pointer over the anchor and click the left mouse button.
The great thing about the anchor portion of the link is that the anchor can be textual or graphical. If a line of text is the anchor, the reader can click on the text to activate the link. If an image is the anchor, the reader can click on the image to activate the link. You can also create an anchor that uses both text and an image. You can insert hyperlinks anywhere in your HTML document: in a paragraph, in an ordered or unordered list, in a table etc.
HTML CODE
I am an undergraduate student at <A
href="http://www.bilkent.edu.tr/"> Bilkent </A> University
PREVIEW
I am an undergraduate student at Bilkent University
The text Bilkent is the anchor of the hyperlink in the above example, and clicking on this anchor links the browser to the web site http://www.bilkent.edu.tr/, which is given in the start tag <A> and is not visible to the reader.
You can add images to your publications with the <IMG> tag. The most important attributes for the <IMG> tag is SRC, which specifies the path to the image. If the image file is in the same directory with the HTML document, then giving only the name of the image file is sufficient. Otherwise, the full path of the file must be given such as H:\Images\aladin.gif. Here is an example.
<img align=center src="aladin.gif">
You can insert tables into your web document by using the <TABLE></TABLE> tags. Many attributes are used to define what tables look like on the page, but you do not have to deal with them for this assignment. After the <TABLE> tag, every pair of <TR> </TR> tags specify a single row in the table, and every pair of <TD> </TD> tags specify a data cell in that row.
HTML
CODE
<TABLE BORDER=1 BORDERCOLOR=black>
<TR>
<TD> xx </TD>
<TD> yy </TD>
<TD> zz </TD>
</TR>
<TR>
<TD> aa </TD>
<TD> bb </TD>
<TD> cc </TD>
</TR>
</TABLE>
PREVIEW
xx |
yy |
zz |
aa |
bb |
cc |