Chapter 5: An Introduction to HTML
HTML is the acronym for the language of the web, hypertext markup language. HTML is merely a set of commands (called "tags") in a text file, which tell a Web browser how to present data. HTML tags are always surrounded by angle brackets (< and >) in the form
, where "TAG" is related to a specific command, and are always closed with a . The angle brackets (< >) allow your browser to distinguish between specific commands and simple text to be displayed on the page. These tags tell the browser how to display the text that is enclosed between the
and the . To understand what tags do, consider how you might get a browser to display a word in bold font. This is easy to achieve; simply surround the word with
and tags. Hence this word is bold because it is in the raw HTML as
bold and this tells the browser to display it as bold. Actually, the tags refer to HTML elements. An element is a fundamental component of the structure of a text document. There are special elements that need to be in every page. All pages need to start with and end with tags. This startup tag informs the browser that it is about to receive a set of commands. The page is then divided into a HEAD and BODY section. The head section starts with a tag and ends with a tag, and holds among other information the page title, that appears on the browser title bar when the page is displayed. The HEAD section also holds most of the scripts (e.g. JavaScript) that will be used in the page. The title is enclosed in TITLE tags, as
This is my page. Then comes the BODY tag, where the content of the webpage will be placed; all visible information (text and images) that you want to display, i.e. the information you want viewers to see, will appear between the BODY tags. The BODY tag has the format This is the visible content of my page. Because you should include these tags in each file, you might want to create a template file with them. Some browsers will format your HTML file correctly even if these tags are not included. But some browsers won't! So make sure to include them. Thus, a typical webpage will have the following basic structure:
Some dumb webpage. Welcome to my webpage. This is my nice webpage. Is it not beautiful? I think it is really beautiful because it is the first webpage that I made. Don't you think that I am cleaver?
Some elements may include an attribute, which is additional information that is included inside the body tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Example: Note: 1. HTML is not case sensitive thus is the same as . 2. The attribute is always xxx= and the attribute value "xxx" in inverted commas. 3. There are no spaces between the attribute and its value. Now we are about to become practical. In the next page you will start doing some exercises in HTML authoring using the built-in tools of KEWL. Meet Your HTML Tutor Now you can launch the KEWL HTML tutor, and use it to type a typical webpage upon which you will then build your HTML knowledge. You should keep the HTML tutor application open throughout this tutorial. If you accidentally close it, you can launch it from any page by using the link to Launch HTML Tutor as it appear alongside. Launch the HTML tutor now, and move to the next page. If you loose track of your windows, look at the launch bar on the bottom of your computer screen. You should see two icons representing the KEWL course, and the HTML tutor.
Click on these icons on the launch bar to switch between the tutor and the course page.
Paragraphs Unlike documents in most word processors, carriage returns in HTML files aren't significant. So you don't have to worry about how long your lines of text are (better to have them fewer than 72 characters long though). Word wrapping can occur at any point in your source file, and multiple spaces are collapsed into a single space by your browser. To indicate paragraph, use the
tag. A browser ignores any indentations or blank lines in the source text. Without
tags, the document becomes one large paragraph. (One exception is text tagged as "preformatted," which is explained on the next page.)
For example:
Level-one heading
Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!
And this is the second paragraph.
To preserve readability in HTML files, put headings on separate lines, use a blank line or two where it helps identify the start of a new section, and separate paragraphs with blank lines (in addition to the
tags). These extra spaces will help you when you edit your files (but your browser will ignore the extra spaces because it has its own set of rules on spacing that do not depend on the spaces you put in your source file). NOTE: The
closing tag can be omitted (this is one of the few exceptions to the general rule of having a start < > tag and an end > tag). This is because browsers understand that when they encounter a
tag, it implies that there is an end to the previous paragraph. Using the
and
as a paragraph container means that you can align a paragraph by including the align=alignment attribute in your source file.
For example, the following codes produce the following visible effects.
This is a centred paragraph.
produces this: This is a centred paragraph.
This is a left aligned paragraph.
produces this:
This is a left aligned paragraph.
This is a right aligned paragraph.
produces this: This is a right aligned paragraph.
The text of this paragraph is stretched to the limits of the horizontal space and is only really obvious when you have constructed a long enough sentence or paragraph to show the effect.
produces this: The text of this paragraph is stretched to the limits of the horizontal space and is only really obvious when you have constructed a long enough sentence or paragraph to show the effect.
Forced Line Breaks The
tag forces a line break with no extra (white) space between lines. Using
elements for short lines of text such as postal addresses results in unwanted additional white space. For example: International Ocean Institute of South Africa
Botany Department, UWC
Modderdam Rd, Bellville
The output is: International Ocean Institute of South Africa Botany Department, UWC Modderdam Rd, Bellville
Heading HTML has six levels of headings, numbered 1 through 6, with 1 being the most prominent. Headings are displayed in larger and/or bolder fonts than normal body text. The first heading in each document should be tagged
. The syntax of the heading element is: Text of heading where y is a number between 1 and 6 specifying the level of the heading. Formatting Text
In an HTML document, you add emphasis to a piece of text by surrounding it with formatting tags. You can change the font type, size, the colour, make it bold, italic, underline it, align it left, right or centre etc. Formatting Attributes:
for bold text for italic text for underlined text for emphasis for strong emphasis size to change font to Comic Sans MS to change the font colour to red Note here that colours have hexadecimal numbers and letters written 0-F. This will be covered next.
The font tag may not be recognised in future version of HTML. It is therefore better to use StyleSheets instead of the tag. Example of the StyleSheets.
Note above that specific attribute values are always placed between inverted commas ("xxx") with no spaces in the entire attribute code. Hexadecimal Colour Values In HTML colours are represent by special numbers. eg. These are six-digit number and letter combinations which represent a colour by giving its RGB (red, green, blue) value. The six digits are actually three two-digit numbers in sequence, representing the amount of red, green, or blue as a hexadecimal value in the range 00-FF. For example, 000000 is black (no color at all), FF0000 is bright red, and FFFFFF is white (fully saturated with all three colors). These number and letter combinations are cryptic. Here are all 216 hexadecimal HTML color codes arranged by hue.
FFF FFF 99C C00 CCF F00 99F F00 66F F00 33F F00 00C C00 33C C33 006 600 003 300 00F F33 00F F66 00F F99 00F FCC 00C C99
CCC 999 666 333 000 CCC 999 666 333 000 CC9 900 CCF 333 666 999 CCC F33 300 600 900 C00 CCF 99C 666 999 CCC F66 C33 633 933 C33 99F 66C 669 999 CCC F66 C33 900 966 C66 66F 339 66C 99F CCC F33 900 C00 F33 C99 33C 336 669 99C CCF C00 600 933 C66 F99 66C 00F 33F 66F 99F C66 F00 F33 F66 F99 336 009 339 669 99C 633 900 933 966 C99 00C 006 339 66C 99F C33 633 966 C99 FCC 33F 009 00C 33F 99F F66 933 C66 F99 FFF 66F 33C 009 66F 66C F99 C66 966 FFF CCC 66F 33C 33F 33C 339 FCC C99 FFF CCC 999 33F 00F 00C 009 006 FCC FFF CCC 999 666 009 9CC
FFC C00 FFC C33 FFF F00 FFF F33 FFF F66 FFF F99 FFF FCC CCF FCC
FF9 900 FFC C66 CC9 933 996 600 996 633 CC9 966 FFC C99
FF6 600 FF9 966 CC6 633 993 300 663 300 CC6 600 FF9 933
FF3 300 FF6 633 330 000 663 333 996 666 CC9 999 FFC CCC
CCF FFF 99C CCC 669 999 336 666 003 333 33C CFF 00C CFF
339 9FF 006 6CC 003 366 006 699 339 9CC 66C CFF 009 9FF
99C CFF 669 9CC 336 699 003 399 336 6CC 669 9FF 006 6FF
FFC CFF CCC CFF 999 9FF 666 6FF 333 3FF 000 0FF 336 6FF 003 3FF
CC3 300 660 000 993 333 CC6 666 FF9 999 FF9 9CC CC9 9CC FF9 9FF CC9 9FF 999 9CC 666 6CC 333 3CC 000 0CC 003 3CC
990 000 CC3 333 FF6 666 FF3 399 CC6 699 996 699 FF6 6FF 996 6CC 993 3FF 666 699 333 399 000 099
CC0 000 FF3 333 990 033 CC0 066 993 366 993 399 FF3 3FF 663 399 660 0CC 330 099 333 366 000 066
FF0 000 CC3 366 CC3 399 990 066 660 033 990 099 FF0 0FF 330 066 660 099 993 3CC 663 3CC 000 033
FF3 366 FF6 699 FF6 6CC FF3 3CC CC0 099 663 366 CC6 6CC 990 0CC CC3 3FF CC6 6FF 996 6FF 663 3FF
CC0 033 FF0 033 FF0 066 FF0 099 FF0 0CC 330 033 660 066 CC3 3CC CC0 0CC CC0 0FF 990 0FF 660 0FF 330 0FF 330 0CC
Formatting tools in KEWL
The current formatting features of the KEWL editor are pretty primitive as we assume that you will be creating content in another editor and pasting it into KEWL1. You can insert tags by clicking the buttons on the toolbar, but the tags are inserted at the end of all text in the window. We will eventually improve this feature, but basically, you would do better to develop your content in another editor such as Frontpage, and then paste the code into the edit window of KEWL. Note: The font and font size dropdown choices do not work in any of the Beta versions of
KEWL. Blockquotes Use the tag to include lengthy quotations in a separate block on the screen. Most browsers generally change the margins for the quotation to separate it from surrounding text. In the example: ….objectives involved in solving the problem as well as the objectives related to the process involved in finding an appropriate solution. Omit needless words.
Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.
--William Strunk, Jr., 1918
1
A WYSWYG editor is currently in development for KEWL based on features of Internet Explorer (it will not work with Netscape or other browsers). It will be available in Version 1.1 of KEWL and may be in place by the time you read this.
the result is: ….objectives involved in solving the problem as well as the objectives related to the process involved in finding an appropriates solution. Omit needless words. Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. --William Strunk, Jr., 1918 Special Characters Sometimes you will need to use special characters that have special meaning to the HTML interpreter, such as the <, >, & and ". You need to use special key combinations, called escape sequences to represent these characters in HTML documents. They are: Use this text < > & " to display this character < > & "
You use escape sequences to display non-ASCII characters, such as an "e" with an umlaut (ë). For a complete listing of these go to http://www.bbsinc.com/symbol.html Note: Escape Tags are case sensitive, unlike other HTML tags Lists HTML supports unnumbered, numbered, and definition lists. You can nest lists too, but use this feature sparingly because too many nested items can get difficult to follow. Unnumbered Lists To make an unnumbered, bulleted list
start by opening the list with the tag (ul - unnumbered list). enter the - tag (li - list item) tag followed by the individual item; no closing tag is needed, although it is not wrong to include
tags. end the entire list with a closing tag.
Below is a sample three-item list: - apples
- bananas
- grapefruit
The output is:
apples bananas grapefruit
Numbered Lists A numbered list (also called an ordered list, from which the tag is name derived) is identical to an unnumbered list, except it uses instead of