Chapter 2
Formatting text
HTML 4.0 was unleashed by the W3C (World Wide Web Consortium). Led by the good people at Massachusetts Institute of Technology, the W3C decided to deprecate most of the following tags and attributes in favour of StyleSheets.
"What ?" , you say. All I mean is these tags will eventually disappear and be replaced with the more powerful concept of StyleSheets (discussed in
Chapter 10). Don't panic, you can still use these tags and be sure they will be interpreted.
Changing the color, size and font of text can help improve the aesthetics of your page. Lets take a look :
To set the text color for your whole page , use the text="" attribute within
the body tag like this:
<body text="red">
To change individual lines of text use this:
<FONT color="purple" size="16" face="Comic sans ms" > type your text here </FONT>
The effect
type your text here
First you open the <FONT> tag, then add the attributes color="specify color" size="specify size" face="specify font style". Remember to surround the values with the " and put a space between the attributes. If you forget the space or misspell the value ,the attributes will be ignored. Play around with the values a little. Enter your favorite color and or font style / face. Easy! Here a the three most common. "Arial" "Helvatica" "Times New Roman"
Lets go a little deeper, ooww!!
To make the text bold use the <B> </B> tags.
To make the text italics use the <i> </i> tags.
To strike the text use the <STRIKE> </STRIKE> tags.
To underline the text use the <U> </U> tags.
To get subscripted characters like in H20 use the <SUB> </SUB> tags.
To get super scripted text like in 102 use the <SUP> </SUP> tags.
I think you can guess what goes between the tags. Insert the text you wish to format. Here's an example :
<FONT color="lime" size="5" face="Arial" >A <B>house </B><U> made</U> of wood</FONT>
The effect
A house made of wood .
Theoretically, you could type your whole script on one line without ever pressing enter. Or , to make it easier to comprehend should you need to make changes at a later date, you could type one tag per line and two blank lines separating different sections. White space in an editor (blank lines) is ignored by the browser and compressed into a single space. Now, you don't want your page to be displayed as one line thats four miles long so make use of the line break tag <BR>. It s the equivalent of pressing return on the keyboard.<P> is like a double line break. Just like a paragraph! Neither the line break or the paragraph tags have closing partners. Check them out.
If you do want the white space you leave in your editor to be reflected by the browser , use the <PRE> </PRE> tags. Any text between these tags will maintain the line breaks and spaces you originally typed.
Let's say you just want to write a comment in your script just to remind you of what you are trying to achieve but you need to hide the text so that it wont be displayed by the browser. Easy, just type <!-- type text here, then close the tag with --> . Here's an example :
<!-- hide text , my first script -->