lesson 1 [introduction, basic html]
lesson 2 [formatting text, colouring text and background]
lesson 3 [images
lesson 4 [lists]
lesson 5 [tables]
lesson 6 [links, imagemaps]
lesson 7 [frames]
lesson 8 [microsoftisms, netscapisms]
lesson 9 [forms]

lesson 2 - let's make it look better - [3 - formatting text, 4 - Colour]
homecommentmore downloadsdownload this

This lesson will teach you how to improve the look of your document. When you are finished you will be able to format text, just like a word processor, you will be able to add colour to your pages along with headings and horizontal lines.

 

<!--3 Formatting text-->

If you have ever used a word processor on your computer you will know the changes you can make to text at the click of a button. Many of these changes can also be made to text in a HTML document except that they are slightly more complicated to enforce.

This chapter will teach you how to enforce these changes to text in a HTML document.

the break tag <br>

please comment when you're finished If you are writing text into a HTML document and you want to skip right to the start of the next line then you might be tempted to do this:

Notepad viewer 3.1a

<html>
<body>
this is an example
of how regardless
of how many times
you press enter
the text will continue
on the same line
until it reaches the
end of the window
</body>
</html>

 


Unfortunately however if you do this your page will look like this:

Explorer View 3.1a - click on the image for a igger and clearer version

The text does not skip to the next line.The way to do it properly is to use the <br> tag. This is a standalone tag in that it has no end tag. Simply entering this in the middle of text skips the proceeding text to the start of the next line. So this is what you would type instead of what is listed in "notepad view 3.1a"(bear in mind that the text now makes no sense as the text does skip to the next line now).

Notepad Viewer 3.1b
<html>
<body>
this is an example<br>
of how regardless<br>
of how many times<br>
you press enter<br>
the text will continue<br>
on the same line<br>
until it reaches the<br>
end of the window<br>
</body>
</html>

Now look below and you will see that using the <br> tag does work.

Explorer Viewer 3.1b - click on the image for a igger and clearer version

the paragraph tag <p> </p>

As is obvious from the heading I have given this section, the <p> tag is used for inserting paragraphs into your documents. If you like you can put a <p> tag at the start of each paragraph and </p> at the end of each but I find that it is much easier to just type <p> in between paragraphs. By this I mean to start off by typing your text, then when you want a new paragraph enter the tag and continue. When you are finished adding text you can just stop straight away instead of adding the </p> tag.

Explorer View 3.2 - click on the image for a igger and clearer version

As you can see using the <p> tag in between paragraphs works fine.

adding preformatted text <pre> </pre>

CAUTION: MAKE CERTAIN TO USE THE </PRE> TAG ONCE YOU ARE FINISHED

please comment when you're finished

Using the <pre> tag is another way of positioning your text the way you want it. It is probably the easiest to use but its drawback is that when preformatted text is used it appears as if written by a mono-spaced typewriter.

Notepad Viewer 3.2 - click on the image for a igger and clearer version

 

Explorer view 3.3 - click on the image for a igger and clearer version

headings <h1>/<h2> etc.

HTML provides the user with six different sized headings. These headings are labeled h1 to h6 with h1 being the largest. To enter a heading first type the start tag e.g.<h2> then type your heading and then your closing tag, which in this case would be </h2>. Why don't you experiment with the different sizes now using "notepad" and your browser.

Headings can be aligned left, center or right by using the "align=" attribute in the starter tag. Heading sizes should be used in descending order so as future browsers can index your site.

the blockquote tag <blockquote> </blockquote>

This tag indents the text that is contained within the start and end tags. It is very effective for making paragraphs stand out.

Notepad Viewer 3.3

<html>
<body>
this text is up against the border
<blockquote>
but by using the blockquote<br>
tag I can indent this<br>
paragraph.<p>
As you can see I can still use the<br>
break and paragraph tags.
</blockquote>
</body>
</html>

Explorer view 3.4 - click on the image for a igger and clearer version

I want the text to look different

So far I've told you how to present the text differently on the page but what about making physical changes to the text. Well here we go!

REMEMBER : WITH ALL OF THESE TAGS IT IS EXTREMELY IMPORTANT THAT YOU INCLUDE THE END TAG

bold

To enforce bold type <b>

To disable bold type </b>

italics

To enforce Italics type <I>

To disable italics type </I>

underline

To enforce underline type <u>

To disable underline type </u>

teletype

Text appears as if typed by a mono-spaced typewriter

To enforce teletype type <tt>

To disable teletype type </tt>

 


strike-through

Text has a line through it like this

To enforce strike-through type <strike>

To disable strike-through type </strike>

superscript

Text is above the level of other text

To enforce superscript type <sup>

To disable superscript type </sup>

subscript

Text is below the level of other text

To enforce subscript type <sub>

To disable subscript type </sub>

small font

Text is presented in a small font

To enforce small font type <small>

To disable small font type </small>

large font

Text is presented in a large font

To enforce large font type <big>

To disable large font type </big>

By using logical thinking it is possible to combine the different tags and end up with different displays.

 

 

please comment when you're finished

Notepad Viewer 3.4

<html>
<body>
<br>this text is <b>bold</b>
<br>this text is <u>underlined</u>
<br>this text is <i>in italics</i>
<br>this text is <small>small</small>
<br>this text is <big>large</big>
<br>this text is <sub>subscript</sub>
<br>this text is <sup>superscript</sup>
<br>this text is <strike>strike-through</strike>
<br>this text is <tt>tele-type</tt>
<br>this text is <b><i>bold italic</b></i>
<br>this text is <u><b>underlined and bold</b></u>
<br>this text is <strike><sup>strike-through and superscript</strike></sup>
<br>this text is <b>bold now</b>,<u> underlined now,<b> bold and underlined now</u>, bold now</b>
<br>
this text is <sub>subscript now,<b><u> bold and underlined and subscript now</sub>, bold and underlined now</u>, bold now</b>
</body>
</html>

I have highlighted above the trickiest part of the listing. Although this may seem quite complicated at first it is quite simple once you think about it and practice a little.

 

Explorer view 3.5 - click on the image to open a bigger and clearer version

logical formatting

There are other things you can type to get the same results as above. The difference with these other tags is that in a few years when computers will read text with emotion these tags will distinguish different emphasis points. I have decided however not to include them because it is easier for you to just learn the physical format commands when starting or else you will end up getting confused. I do.

the basefont tag

You can set the font of your page to any font you have on your hard disk. You must however bear in mind that if you put your page on the WWW then it is possible that not all those viewing your page will have that font on their hard disk. If this happens then your page will not be presented in the way that you wanted.

The most common fonts you will find on a computer are Times New Roman and Arial. Therefore if it is important to you that everyone view your site the same way that you do then these are the two you should probably go for.

Another option you could go for is selecting two or more different fonts that your text could be presented in. For example you could set your first choice font as say "verdana", your second choice as "lucida casual" and your third choice as "times new roman". I recommend however that your last choice be either "times new roman" or "arial" therefore if the person viewing your site has none of the other fonts the page will still present properly.

please comment when you're finished

The following are the attributes of the basefont tag:

 

  • Face
  • Color
  • Size

Face means font

to set the font type : <basefont face="font">

to select more than one font type : <basefont face="font1","font2","font3">

Color (it's the American spelling that is used) will be discussed in detail in chapter 4.

Size sets the size of the font and is measured on a scale of 1 to 7 with 3 being a normal size font.

To set the size type : <basefont size=3>

You can include as many of the above attributes as you like.

e.g. <basefont face="lucida casual" size=5>

Netscape does not support the basefont tag. It does however support the font tag, as do all browsers.

the font tag

The font tag uses the same attributes of the <basefont> tag. It also has a major difference in that it requires an end tag.

The purpose of the <font> tag is to change the font in the middle of the document but only for a certain period.

The font tag makes no difference at all unless attributes are set in the start tag.

e.g. <font face="verdana" size=3 color=#ff0000> this text is in verdana </font>

If you have set the basefont size to 2 and you want to change it to 4 using the font tag then you can use this attribute:

<font size=+2>this text is 2 sizes bigger than the rest</font>

 

<!--4 Colouring text and background-->

please comment when you're finished

You saw at the end of the last chapter that I set the colour of the font to "#ff0000" which is the rgb value for red. What is rgb value? The rgb value of a colour is the amount of red, green and blue that are combined to display that colour on your monitor. To list a colour in a HTML document you must display it with a # sign in front of it and then 6 characters, 2 for each amount, defining the rgb value. You can use any ammount from 0 to 255 of each colour. You do not use decimal numbers however, you must use hexadecimal notation, to convert a decimal number to hexadecimal notation I have made a program for you to download.

However the designers of HTML have copped on to the fact that very few people do actually understand how to picture a color based solely on its rgb value so now there are 16 colours which you can add to your document simply by defining the color as that colour, i.e. color=red. Here now is a complete listing of the colours you can use without knowing their rgb value.

Black #000000

Silver #C0C0C0

Gray #808080

White #FFFFFF

Maroon #800000

Red #FF0000

Fuchsia #FF00FF

Green #008000

Lime #00FF00

Olive #808000

Yellow #FFFF00

Navy #000080

Blue #0000FF

Teal #008080

Aqua #00FFFFF

You can use these colours for either text or background. You will learn how to colour text and backgrounds in a short while.

colouring text

By using information gathered in the last chapter and at the start of this chapter you probably have already figured out how to colour your text if not then read on.

Text colour can be set in three places. In two of those places it is set using the "color=?" attribute and in the other it is set using the "text=?" attribute.

colouring text by using the <body> tag

The <body> tag has several attributes relating to text colour in a document. The first which is used for setting the colour of regular text looks like this: <body text=aqua>

You will learn more about links in chapter 8 but for now you will just learn how to change the colour of links in text. To specify the colour of a link in text simply use the attribute "link=?" for example <body link=blue>

There are two other colours that can be set concerning links, these are the colours for a visited link and an active link. A visited link is a link that you have already visited (to state the obvious). An active link is a link that is open, this is only ever viewed when a page has multiple frames (you will learn more about frames in chapters 10, 11 and 12). To set the colour of a visited link use the attribute "vlink=?" and to set the colour of an active link use the attribute "alink=?". For example: <body vlink=green alink=aqua>

colouring text by using the <basefont> or <font> tags

Both of these tags use the same attribute to set or change the colour of font. When you learned about these tags in the last chapter you learned about attributes such as "face" and "size". Well to set the colour you simply use the attribute "color" e.g. <basefont color=red>

or

<font color=red>red</font>

colouring the background

There are two ways to enhance your background with colour, you can:

A add a colour to it

B add a tiled image to it

A add a colour to it

To add a colour to your background you simply use this attribute in the <body> tag: "bgcolor=?". If you are overwhelmed by the amount of attributes of the <body> tag do not worry because I will provide a complete listing of these attributes at the end of the chapter.

please comment when you're finished e.g. <body bgcolor=red>

B add a tiled image to it

This is the first example you have come across so far of adding an external file to your HTML document. Before you do anything with your HTML code I recommend that you move the image you want to use into the same directory as the HTML document. Therefore you will not need to specify a full path to the image.

Assuming that your image is now in the same directory as your HTML document this is the attribute of the <body> tag that you would use:

<body background="image.gif">

but be careful some images are just not meant to be tiled

This is a bad image to use for tiling because it does not repeat very well. By this I mean that the edges do not correspond. It will also be difficult to add text on top of this background because it will not be easily visible. These are the two factors you must take into account when choosing a background.

Explorer View 4.1 - click on the image for a igger and clearer version

The best idea is to tile a very small image that ends up looking just like one image. Take for example Explorer view 4.2 this is a perfect example because the tiled image looks like one image and the text is easily visible.

Explorer View 4.2 - click on the image for a igger and clearer version

Explorer View 4.3 - click on the image for a igger and clearer version

If you set a tiled image for your background you should also include a bgcolor attribute similar to the colour of your image so as those people viewing with pictures turned off, or with text only browsers, will still be able to read your text easily. Take for example Explorer View 4.3. This is the same page but the person viewing has pictures turned off. If there was no bgcolor set then the background would be either grey or the colour set by the viewer.

You can see in Notepad Viewer 4.1 below how you would use both a background image and a background colour so as to cater for text only browsers and those with pictures turned off. The two results of this document can be seen in Explorer View 4.2 and 4.3 above.

Notepad Viewer 4.1

<html>
<head>
<title>Make sure your text is visible
</title>
</head>
<body text=white background="circles.gif" bgcolor=#000099>
This text is visible because it is in contrast with the background
</body>
</html>

please comment when you're finished bgproperties=

The only property that can be set for this attribute is "fixed". It is also only compatible with Microsoft Internet Explorer. There is no point in including this attribute if you do not plan on setting it to fixed or if you do not have a tiled image set as your background.

If you include this attribute (set to fixed) then your background image will not scroll when the page is scrolled. Instead the text and other components of the page will scroll over it.

separating text by using horizontal lines <hr>

If you have ever surfed the net you may have noticed that a lot of websites separate their text using horizontal lines.

To insert a horizontal line simply use the tag <hr> anywhere in your document. A new paragraph is automatically started after the line.

The <hr> tag also has attributes. These are: size, width, color, and align.

Size sets the thickness of the line in pixels

Width sets the width of the line as a percentage of the viewing screen

Color sets the colour of the line using either rgb value or one of the presets

Align sets the alignment to left, right or center.

Notepad Viewer 4.2

<html>
<head>
<title>Horizontal Lines
</title>
</head>
<body >
<basefont >
this text is above the first horizontal line
<hr size=2 width=75% color=red align=right>
this text is between the first and second horizontal lines
<hr size=4 width=50% color=black align=center>
this text is between the second and third horizontal lines
<hr size=2 width=75% color=red align=left>
this text is after the third horizontal line
</body>
</html>

Explorer View 4.4 - click on the image for a igger and clearer version

You can see above different ways in which you can present horizontal lines.

lesson 1 [introduction, basic html]
lesson 2 [formatting text, colouring text and background]
lesson 3 [images
lesson 4 [lists]
lesson 5 [tables]
lesson 6 [links, imagemaps]
lesson 7 [frames]
lesson 8 [microsoftisms, netscapisms]
lesson 9 [forms]
It is also possible to use graphics as horizontal lines. These however take time to download and they do not appear on browsers with pictures turned off or with text only browsers. HTML horizontal lines take very little time to download and appear on all browsers.

 

I promised you a table with all the attributes of the <body> tag, so here it is:

 

<body>  
topmargin= measured in pixels
leftmargin= measured in pixels
text= colour
link= colour
vlink= colour
alink= colour
bgcolor= colour
background= image
bgproperties= "fixed" is only result
 

I have not included the results of each attribute because they have already been discussed in detail earlier in the book. The only reason for this table is reference.

If you set one colour in a HTML document you should set them all otherwise the colours set by the viewers browser might clash with the one you have selected. For example if you only set your text to aqua and the viewer has his browser set to display a background as aqua then that person will not see any text on your page.

 



next lesson    home    comment    more downloads    download this
lesson 1 [introduction, basic html]
lesson 2 [formatting text, colouring text and background]
lesson 3 [images
lesson 4 [lists]
lesson 5 [tables]
lesson 6 [links, imagemaps]
lesson 7 [frames]
lesson 8 [microsoftisms, netscapisms]
lesson 9 [forms]

HTML Builder- End of Lesson 2

Notepad Viewer- HTML Builder 2

<html>

<head>

<meta name=keywords content="practice, web, page, html">

<meta name=description content="this is the site I will use to practice writing HTML">

<title>

I have now completed Lesson

2

</title>

</head>

<body topmargin=20 leftmargin=15

text=fuchsia link=navy vlink=blue alink=green background="nonexistent.jpg" bgcolor=aqua bgproperties=fixed>

<basefont face="lucida casual","arial" size=3 color=fuchsia>

<h1 align=center>

This is what I have learned
</h1>

<hr size=3 color=lime width=75% align=center>

<h2>

I have now finished lesson 1
</h2>

<hr size=3 width=75% color=lime align=left>

I know the very basics of writing HTML. I know that the start and end HTML tags are necessary in a HTML document. I know that the meta tag is used to give information to search engines, i.e keywords and description

<p>

I am able to assign a title to my documents (see taskbar above).

<br>

I know that all text and images etc. are to be included between the start and end body tags. I know two attributes of the start body tag, topmargin and leftmargin and I know that each of these is measured in pixels. I know how to insert hidden text in a HTML document for example there is hidden

<!--this text is hidden so you cannot see it on the webpage-->

text in between the words hidden and text in this sentence.

<hr size=3 width=75% color=lime align=left>

<h2>I have now finished lesson 2</h2>

<hr size=3 width=75% color=lime align=left>

Most of what I learned in lesson two was about changing the look of my webpage. I have already made some changes to this page and I will tell you what they are in an indented paragraph.

<blockquote>

As you can see I have added a background colour to the page and if I want I know how to add a tiled image. I have set all of the attributes in the body tag, most of them concern the colour of different text. I have added paragraphs and line breaks to the text. I have set the basefont tag and

<font face="flexure","times new roman" size=+1 color=black>

know how to use the font tag </font>.

I have added horizontal lines and I have added headings. I have also added paragraphs and line breaks.

</blockquote>

<pre>

I am able to

-----------------

use preformatted text to make

it appear in the order

I want it to

</pre>

<p>I can format my text so as it is<br>

<b>bold</bold><br>

<i>in italics</i><br>

<u>underlined</u><br>

<tt>tele-type</tt><br>

<strike>strike-through</strike><br>

<sup>superscript</sup>,

<sub>subscript</sub><br>

<small>small</small><br>

<big>big</big><br>

<b><u><i>or

</i></b><sup><big> a

</u></sup><tt><strike> combination</big></tt></strike>

</body>

</html>

 

Congratulations! You've made it this far. Isn't it weird to scroll through your code in Notepad and see all the script that goes into making a web page. I'm sorry to inform you however that you have only just begun. In the next few chapters you will learn how to spice up your pages using images, tables and lists.

I'm sorry that I could not provide a picture of the page as it now looks but as you know yourself, if you've already updated your HTML practice document, it is too long to fit on the screen.

Please tell me what you think
name

email

website

comments





 


next lesson    home    comment    more downloads    download this


Information
The official home-page where this document can be downloaded is http://www.geocities.com/SiliconValley/Network/4759/
This document (whole or part) is not to be used, plagiarised, or its' content attributed to any other author. Any quotes must be acknowledged to the author and the author must be informed of the quotation before it's publication. This is effective whether the quotation is being transmitted by electronic or any other means. The author of this document is Oisin Prendiville who can be contacted at
html3.2@technologist.com

This document was last modified by the author (above) on 5/12/98
© copyright 1998