HTML Text Formatting

HTML Text Formatting


HTML Text Formatting

Different tags to format text are as follows:

Bold

<B> tag is used to display text in bold face style. It is closed by </B> tag.
Example
<B> Formatting makes things cool. </B>

Italic

<I> tag is used to display text in italic style. It is closed by </I> tag.
Example
<I> Italic text looks stylish.</I>

Underline

<U> tag is used to display text as underlined. It is closed by </U> tag.
Example
<Us Underlined text looks prominent </U>

Superscript

<SUP> lag is used to display text as superscript. It is closed by </SUP> tag.
Example
N<SUP>2</SUP>
The above example will display N2

Subscript

<SUB> tag is used to display text as subscript. It is closed by </SUB> tag.
Example
N<SUB>2</SUB>
The above example will display N2

Now take a look how to do this.

Practical

1. Open Notepad and týpe the following code

<HTML>
<B>Bold</B><BR>
<I>Italics</I><BR>
<U>Underline</U><BR>
X<SUP>3<SUP><BR>
H<SUB>2</SUB>0<BR>
<HTML>

2. Save the file as Text.html

3. Double click the file. The web page will appear in the browser as follows

HTML Text Formatting



Fonts

<FONT> tag is used to specify the characteristics of font. Different characteristics include the typeface, size and color. It is closed with </FONT> tag.

Attributes

Some important attributes of FONT tag are as follows:
Attribute

FACE

It specifies the font of the text. The possible values are Arial
Arial Black" "Courier" and "MS sans Serif" etc.

SIZE

It specifies the font size of the text. It can be from 1 to 7. The default size is 3. The size can also be given as relative to the default size. The size 1 displays 8pt size, size 2 displays 10pt and so on.

COLOR

It specifies the color of the text. It can be given as color name or hexadecimal value of the color.

The following are colors with hexadecimal values.

Red
# FF0000

Green
#00FF00

Blue
#0000FF

White
#FFFFFF

Black
#000000

Gray
#808080

Dark Red
#800000

Dark Green
#008000

Yellow
#FFFF00


Example
<FONT SIZE=+2 FACE-"Verdana">Verdana</FONT><BR>
<FONT SIZE=+2 FACE-"Arial">Arial</FONT><BR>
<FONT SIZE=+2 FACE-"Helvetica">Helvetica</FONT><BR>
<FONT SIZE=+2 FACE="Impact">Impact</FONT><BR>
<FONT SIZE=+2 FACE-Comic Sans MS">Comic Sans MS</FONT><BR>

Practical

Open Notepad and type the following code
<HTML
<BODY>
<FONT FACE "Arial" SIZE="11">One Size Larger</FONT> <BR>
<FONT SIZE="-1" COLOR "red"> Small & Colorful</FONT>
</BODY>
</HTML>

2. Save the file as "Font.html"
3. Double click the file. The web page will appear in the browser as follows

HTML Text Formatting


<BIG> and <SMALL> Tags

<BIG> and <SMALL> tags change the relative size of text with respect to surrounding text. <BIG> tag makes the text a little bigger and <SMALL> tag makes the text a little smaller.

However, different browsers display effect of these tags differently. In Internet Explorer, text formatted with <BIG> tag is always one size larger than the surrounding text. The tag has no effect if the size of surrounding text is 7. The text formatted with <SMALL> is one size smaller than surrounding text. The tag has no effect if the size of surrounding text is 1.


Example
The following line will display the test one size larger than normal size.
<BIG>Hello World</BIG>

The following line will display the text one size smaller than normal size.
<SMALL> Hello World </SMALL>

Preformatted Text

This tag is used to display the text as the user has typed. HTML ignores extra line breaks and the text appears in single line The text is placed between <PRE> and </PRE> tags.