HTML allows text to be displayed with a great deal of flexibility. This page explains how HTML tags provide text formatting instructions for browsers.
It is very important to realize that individual users can change how a page will display by changing browser preferences. It is best to test how a page will display in different browsers before posting it to the Web.
Web browsers generally ignore extra spaces and returns in HTML code. In order to force a line break, the <BR> (BReak) tag is used. Simply add this tag where you want the line break to occur.
The <BR> tag has no attributes or closing tag.
Example: The <BR> tag |
---|
Without the <BR> tag this line would run to the end of the window;
but the <BR> tag forces the line to break wherever the <BR> tag occurs.
The <BR> tag is simple and practical.
____________</Example> |
Result: |
---|
Without the
tag this line would run to the end of the window; but the tag forces the line to break wherever the tag occurs. The tag is simple and practical. ____________</Example> |
Text can be modified with the <FONT> tag to change color, size, or typeface. The <FONT> tag follows the same rules for order of opening and closing tags; where the last tag opened should be the first tag closed.
You can specify a relative or absolute SIZE to a font.
The valid SIZEs are 1 to 7.
The default is 3.
Using the + or - characters will change the SIZE by that amount.
Example: The SIZE attribute, absolute examples |
---|
<FONT SIZE=1>THIS IS SIZE 1</FONT> <FONT SIZE=2>THIS IS SIZE 2</FONT> <FONT SIZE=3>THIS IS SIZE 3</FONT> <FONT SIZE=4>THIS IS SIZE 4</FONT> <FONT SIZE=5>THIS IS SIZE 5</FONT> <FONT SIZE=6>THIS IS SIZE 6</FONT> <FONT SIZE=7>THIS IS SIZE 7</FONT> ____________</Example> |
Result: |
---|
THIS IS SIZE 1 THIS IS SIZE 2 THIS IS SIZE 3 THIS IS SIZE 4 THIS IS SIZE 5 THIS IS SIZE 6 THIS IS SIZE 7 ____________</Result> |
Example: The SIZE attribute, relative examples |
---|
The SIZE attribute works best when used for
<FONT SIZE=+2>emphasis</FONT> in body copy or that
<FONT SIZE=-2>fine print</FONT> that no one really reads.
Nesting SIZEs with relative changes may lead to unexpected or undesirable results.
____________</Example> |
Result: |
---|
The SIZE attribute works best when used for
emphasis in body copy or that
fine print that no one really reads.
Nesting SIZEs with relative changes may lead to unexpected or undesirable results.
____________</Result> |
Colors can be specified with either a name or a hexadecimal value (hex triplet).
Not all browsers will recognize all color names, so it is safer to use a hex triplet to identify a color.
A hexadecimal number is a base 16 number.
The base 10 number system uses digits 0-9.
Hexadecimal numbers also use A-F for 10-15 where:
A=10 | B=11 | C=12 | |||||
D=13 | E=14 | F=15 |
A hex triplet is a pound sign (#) followed by a set of 3 pairs of hexadecimal numbers.
Example: The COLOR attribute |
---|
The color <FONT COLOR="RED"> red </FONT> may be
specified with the color name <FONT COLOR=#FF0000> RED </FONT>
or with the hex triplet #FF0000.
____________</Example> |
Result: |
---|
The color red may be
specified with the color name RED
or with the hex triplet #FF0000.
____________</Result> |
Appendix B and Appendix C have more information on using color names and hex triplets.
Font typefaces can be specified with the FACE attribute.
Not all browsers will recognize this attribute, and even if they do, the font must be installed for the attribute to work. Different platforms and font names can make this attribute difficult to implement.
A font is a style of type. Fonts come in families (bold, italic, etc.).
There are serif fonts (with flared ends) and sans serif fonts (no flared ends). A monospaced font is one where each character takes up the same amound of horizontal space like a typewriter.
Example: The FACE attribute |
---|
Common serif fonts are <FONT FACE="Times, Times New Roman, Garamond">
Times, Times New Roman, and Garamond </FONT>.
Common sans serif fonts are <FONT FACE="Arial, Helvetica, Futura, Avant Garde">
Arial, Helvetica, Futura, and Avant Garde </FONT>.
A common monospace font is <FONT FACE="Courier">
Courier </FONT>.
____________</Example> |
Result: |
---|
Common serif fonts are
Times, Times New Roman, and Garamond .
Common sans serif fonts are
Arial, Helvetica, Futura, and Avant Garde .
A common monospace font is
Courier .
____________</Result> |
Note that more than one font name may be specified. Browsers generally use the first match that is encountered.
HTML allows for six (6) levels of headings (H1 through H6). The code for headings is enclosed with <H1>...</H1> tags.
Example: The 6 Heading Tags |
---|
<H1>This is Heading Level 1</H1> <H2>This is Heading Level 2 </H2> <H3>This is Heading Level 3</H3> <H4>This is Heading Level 4</H4> <H5>This is Heading Level 5</H5> <H6>This is Heading Level 6</H6> ____________</Example> |
Result: |
---|
This is Heading Level 1This is Heading Level 2This is Heading Level 3This is Heading Level 4This is Heading Level 5This is Heading Level 6____________</Result> |
There are several text formatting tags. Remember, not all tags will work with all browsers. Combinations can produce unexpected results. Test!
Example: The <B> Tag |
---|
A sample of the Bold Tag: <B>ABCDEFGhijklmnop QRSTUV wxyz</B>
____________</Example> |
Result: |
---|
A sample of the Bold Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <I> Tag |
---|
A sample of the Italic Tag: <I>ABCDEFGhijklmnop QRSTUV wxyz</I>
____________</Example> |
Result: |
---|
A sample of the Italic Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <TT> Tag |
---|
A sample of the Monospace Tag: <TT>ABCDEFGhijklmnop QRSTUV wxyz</TT>
____________</Example> |
Result: |
---|
A sample of the Monospace Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <U> Tag |
---|
A sample of the Underline Tag: <U>ABCDEFGhijklmnop QRSTUV wxyz</U>
____________</Example> |
Result: |
---|
A sample of the Underline Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <S> Tag |
---|
A sample of the Strikethrough Tag: <S>ABCDEFGhijklmnop QRSTUV wxyz</S>
____________</Example> |
Result: |
---|
A sample of the Strikethrough Tag: ____________</Result> |
Example: The <BIG> Tag |
---|
A sample of the Big Tag: <BIG>ABCDEFGhijklmnop QRSTUV wxyz</BIG>
____________</Example> |
Result: |
---|
A sample of the Big Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <SMALL> Tag |
---|
A sample of the Small Tag: <SMALL>ABCDEFGhijklmnop QRSTUV wxyz</SMALL>
____________</Example> |
Result: |
---|
A sample of the Small Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <SUB> Tag |
---|
A sample of the Subscript Tag: <SUB>ABCDEFGhijklmnop QRSTUV wxyz</SUB>
____________</Example> |
Result: |
---|
A sample of the Subscript Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <SUP> Tag |
---|
A sample of the Superscript Tag: <SUP>ABCDEFGhijklmnop QRSTUV wxyz</SUP>
____________</Example> |
Result: |
---|
A sample of the Superscript Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <EM> Tag |
---|
A sample of the Emphasize Tag: <EM>ABCDEFGhijklmnop QRSTUV wxyz</EM>
____________</Example> |
Result: |
---|
A sample of the Emphasize Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <STRONG> Tag |
---|
A sample of the Strong Tag: <STRONG>ABCDEFGhijklmnop QRSTUV wxyz</STRONG>
____________</Example> |
Result: |
---|
A sample of the Strong Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <CODE> Tag |
---|
A sample of the Code Tag: <CODE>ABCDEFGhijklmnop QRSTUV wxyz</CODE>
____________</Example> |
Result: |
---|
A sample of the Code Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <SAMP> Tag |
---|
A sample of the Sample Tag: <SAMP>ABCDEFGhijklmnop QRSTUV wxyz</SAMP>
____________</Example> |
Result: |
---|
A sample of the Sample Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <CITE> Tag |
---|
A sample of the Citation Tag: <CITE>ABCDEFGhijklmnop QRSTUV wxyz</CITE>
____________</Example> |
Result: |
---|
A sample of the Citation Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <DFN> Tag |
---|
A sample of the Definition Tag: <DFN>ABCDEFGhijklmnop QRSTUV wxyz</DFN>
____________</Example> |
Result: |
---|
A sample of the Definition Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <KBD> Tag |
---|
A sample of the Keyboard Tag: <KBD>ABCDEFGhijklmnop QRSTUV wxyz</KBD>
____________</Example> |
Result: |
---|
A sample of the Keyboard Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Example: The <VAR> Tag |
---|
A sample of the Variable Tag: <VAR>ABCDEFGhijklmnop QRSTUV wxyz</VAR>
____________</Example> |
Result: |
---|
A sample of the Variable Tag: ABCDEFGhijklmnop QRSTUV wxyz
____________</Result> |
Your browser will generally strip any extra white space in a file. Spaces and returns (or line breaks) that are part of the HTML file are generally ignored.
Text formatted with the <PRE> tag is generally displayed in a monospaced font like Courier (of course, users may mistakenly change the font in their browser preferences to a non-monospace font).
The <PRE> tag is similar to doing type on a typewriter or dot-matrix printer.
Example: The <PRE> Tag |
---|
A sample of the Preformatted Text Tag: <PRE>ABCDEFGhijklmnop QRSTUV wxyz</PRE>
____________</Example> |
Result: |
---|
A sample of the Preformatted Text Tag: ABCDEFGhijklmnop QRSTUV wxyz ____________</Result> |
Example: Better example of the <PRE> Tag |
---|
THINK DOT MATRIX: 12345678901234567890123456789012345678901234567890 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X X X TTTTT H H I NN N K KK X X T H H I NNN N K KK X X T HHHH I N NN N KKK X X T H H I N NNN K KK X X T H H I N NN K KK X X X X DDD OO TTTTT X X D D O O T X X D D O O T X X DDD OO T X X X X MMM MMM AA TTTTT RRRR I X X X X M MMM M A A T R R I X X X X M M M AAAA T RRRR I X X X M M A A T R RR I X X X X M M A A T R R I X X X X X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ____________</Example> |
A special character is any character that requires a key combination anything more complex than holding down the shift key to be produced.
Getting special characters to display properly involves the use of character entities. There are two forms of character entities: numbered entities and named entities.
Numbered entities use an ampersand, a number sign, a 2 or 3 digit code, and a semicolon to identify the character.
Example: Numbered entities |
---|
& produces & (Ampersand) " produces " (Quotation mark) © produces © (Copyright) ® produces ® (Registered trademark) < produces < (Less than) > produces > (Greater than) ____________</Example> |
Named entities use an ampersand, a number sign, a name for the character they represent, and a semicolon to identify the character.
Example: Named entities |
---|
& produces & (Amperstand) " produces " (Quotation mark) © produces © (Copyright) ® produces ® (Registered trademark) < produces < (Less than) > produces > (Greater than) ____________</Example> |
As with other elements of HTML, not all named entities will work with all browsers and numbered entities may display different characters in different browsers. Test!
A table with a listing of the named and numbered entities is listed in Appendix A.
Note on arcane tags that are rarely used:
In contrast, if you do not want a line to break, you can force the type to remain on a
single line using <NOBR>...</NOBR> tags. The extension <WBR> (word break)
may be used inside the <NOBR>...</NOBR> tags to indicate where a break may occur.
The <WBR> tag does not force a line break, but will break the type if it is appropriate.
If the line of type fits on the screen, the <WBR> tag is ignored.
The <ADDRESS> tag is used to sign-off on Web pages. They usually go at the bottom of the page and contain the name of the Webmaster (or company that created the page), a contact person, the date the last time the page was updated, copyright notices, and anything else that seemed important at the time the page was done. They are usually offset by a horizontal rule.
Example: The <ADDRESS> Tag |
---|
<ADDRESS>
<HR>
<BR>
Last updated 1 December 1996<BR>
Created by Ken Kaleta: kenk@servtech.com<BR>
Copyright Ken Kaleta 1996 all rights reserved
</ADDRESS>
____________</Example> |
Result: |
---|
Last updated 1 December 1996 Created by Ken Kaleta: kenk@servtech.com Copyright Ken Kaleta 1996 all rights reserved ____________</Result> |
Although <CITE>...</CITE> and <CODE>...</CODE> will bring emphasis to short quotes, bits of code, math equations, book and magazine titles and the like, HTML also offers the <BLOCKQUOTE>...</BLOCKQUOTE> tags for longer quotes.
Generally, the format is to give the quote some space above and below, and to indent the text. Line breaks <BR> can be used to force breaks. The following poem is within <BLOCKQUOTE>...</BLOCKQUOTE> tags:
Example: The <BLOCKQUOTE> Tag |
---|
A poem using the BLOCKQUOTE Tag:
There are little eyes upon you ____________</Example> |
The <BLINK>...</BLINK> tags will set type to blink. This is often very annoying and should be avoided.
Example: The <BLINK> Tag |
---|
A sample of the Blink Tag: <BLINK>ABCDEFGhijklmnop QRSTUV wxyz</BLINK>
____________</Example> |
Result: |
---|
A sample of the Blink Tag:
____________</Result> |