Chapter 4. Formatting Text

You can apply formatting tags to control the appearance of text on your Web page. This chapter shows you how to add attributes and tags to make your text look its best.

Formatting Text

Make Text Bold 52

Italicize Text 53

Add Underlining to Text 54

Change Fonts 55

Change Font Size 56

Change the Text Color 58

Adjust Margins 60

Set a Background Page Color 61

Add a Horizontal Line 62

Make Text Bold

You can add bold formatting to your text to give it more emphasis or make your page more visually appealing. For example, you might make a company name bold in a paragraph or add bold to a list of items.

Make Text Bold

Make Text Bold

1 Type <B> in front of the text you want to make bold.

2 Type </B> at the end of the text.

• When displayed in a Web browser, the text appears as bold.

Note

To create bold text using the font-weight property in CSS, see Chapter 11.

Make Text Bold

Italicize Text

You can add italics to your text to give it more emphasis or make your page more visually appealing. For example, you might italicize a description under a heading to distinguish it from the rest of the page.

Italicize Text

Common uses for italicized text include emphasizing a new term or setting apart the title of a literary work.

Italicize Text

1 Type <I> in front of the text you want to italicize.

2 Type </I> at the end of the text.

• When displayed in a Web browser, the text appears in italics.

Note

To italicize text using the font-style property in CSS, see Chapter 11.

Italicize Text

Add Underlining to Text

You can add underlining to your text for added emphasis. For example, you might underline a term or an important name.

Use caution when applying underlining to Web pages because some users may mistake the underlined text for a hyperlink. See Chapter 6 to learn more about using links in Web pages.

Add Underlining to Text

Add Underlining to Text

1 Type <U> in front of the text you want to underline.

2 Type </U> at the end of the text.

• The text appears underlined on the Web page.

Note

To underline text using the text-decoration property in CSS, see Chapter 11.

Add Underlining to Text

Change Fonts

You can change the appearance of your text using the tags <FONT> and </FONT>, along with the FACE attribute. You can use the attribute to specify a font by name.

Not all Web browsers can display all fonts. It is best to assign common fonts typically found on most computers, such as Times New Roman and Arial. It is also a good idea to list more than one font name in the FACE attribute, in case the first font is not available on the viewer's computer.

Change Fonts

Change Fonts

1 Type <FONT FACE="?"> in front of the text you want to change. Replace ? with one or more font names or families, separated by commas.

If the first font you list is not available on the user's computer, the second font will be used.

Commonly supported font families are serif, sans serif, and monospace.

2 Type </FONT> at the end of the text.

• The text appears in the new font on the Web page.

Note

Note: To change the font using the font-family property in CSS, see Chapter 11.

Change Fonts

Change Font Size

You can change the font size of your Web page text using the SIZE attribute. You can specify seven font sizes in HTML. Font Size 1 creates the smallest text, while Font Size 7 creates the largest.

While the SIZE attribute lets you set the text size for a section of text, the <BASEFONT> tag lets you set the font size for the entire page.

Change Font Size

Change Font Size

CHANGE A SECTION OF TEXT

1 Type <FONT SIZE=" ? "> before the text you want to change, replacing ? with a number from 1 to 7.

2 Type </FONT> at the end of the text.

3 Type additional <FONT> tags and SIZE attributes for any other text that you want to size.

• The text appears at the designated font size on the Web page.

This figure shows samples of all seven font-size levels.

Note

To change the font size using the font-size property in CSS, see Chapter 11.

Change Font Size

CHANGE ALL THE TEXT

1 Type <BASEFONT SIZE=" ?"> at the top of your Web page text, replacing ? with a size you want from 1 to 7.

All the text appears at the new size in the Web browser.

Note

The <BASEFONT> tag does not affect the size of any headings (<H1>) within your Web page text.

Change Font Size

Tip

At what size will my text appear in my page if I size it using the SIZE attribute?

The exact size of the text depends on which browser you use, although most modern browsers display at the same sizes. This table shows at what sizes Internet Explorer 6 and Firefox 2 display text.

Size Attribute

Font Size

1

7 points

2

10 points

3

12 points

4

14 points

5

18 points

6

24 points

7

36 points

Can I set a size using something other than the seven size levels?

Yes, using relative font sizing. If you type a plus (+) or minus (-) sign before a size number, the browser displays text at a size that is relative to the surrounding text. For example, if you type <FONT SIZE="+2">, the browser displays the text two sizes larger than the surrounding text. If you type <FONT SIZE="-2">, the browser displays the text two sizes smaller than the surrounding text.

Change Font Size

Change the Text Color

You can enhance your text by adding color. The COLOR attribute works with the <FONT> tag to change text on a page from the default black to a color. You can specify the color using a hexadecimal value or, for certain common colors, the color's name.

Change the Text Color

Legibility is always a concern when it comes to applying color attributes to text. Be sure to choose a color that is easy to read on a Web page. Use caution when applying colored text to a colored background. Always test your page to make sure the colors do not clash and your text remains legible.

Change the Text Color

CHANGE A SECTION OF TEXT

1 Type <FONT COLOR=" ?"> in front of the text you want to change, replacing ? with the name or hexadecimal value of the desired color.

This example shows the color name for red.

2 Type </FONT> at the end of the text.

• The text appears in the designated color on the Web page.

Note

To change the font color using the color property in CSS, see Chapter 11.

Change the Text Color

CHANGE ALL THE TEXT

1 Within the <BODY> tag, type TEXT=" ?", replacing ? with the name or hexadecimal value of the desired color.

This example uses a hexadecimal value instead of a color name. Always precede a hexadecimal value with a # sign.

All the text appears in the new color in the Web browser.

• Text that you have colored using the FONT tag remains that color.

Note

The TEXT attribute does not affect the color of links. To learn more about links, see Chapter 6.

Change the Text Color

Tip

What colors can I set for my Web page text?

HTML coding sets colors using six-digit hexadecimal values preceded by a number sign (#), as shown in the table. Browsers can also understand the color names listed here.

Color

Hexadecimal Value

Aqua

#00FFFF

Black

#000000

Blue

#0000FF

Fuchsia

#FF00FF

Gray

#808080

Green

#008000

Lime

#00FF00

Maroon

#800000

Navy

#000080

Olive

#808000

Purple

#800080

Red

#FF0000

Silver

#C0C0C0

Teal

#008080

White

#FFFFFF

Yellow

#FFFF00

Adjust Margins

You can adjust the margins of your Web page to change the amount of space that appears at the top, bottom, left edge, or right edge. By default, the HTML margins are set at approximately 10 pixels. You can adjust the settings to suit your design needs.

Adjust Margins

Adjust Margins

1 Within the <BODY> tag, type MARGIN=" ?".

Replace MARGIN with the margin attribute you want to change: LEFTMARGIN, RIGHTMARGIN, TOPMARGIN, BOTTOMMARGIN, MARGINWIDTH, or MARGINHEIGHT.

Replace ? with the amount of indentation you want, measured in pixels.

You can set the margin for one side of the page or all four sides, all within the <BODY> tag.

• The Web browser displays your page with the specified margins.

Note

To learn how to change the alignment of text on a page, see Chapter 3.

Note

To adjust margins using style sheets, see Chapter 12.

Adjust Margins

Set a Background Page Color

You can add color to the background of the page using the BGCOLOR attribute. It is a good idea to choose a background color that does not obscure your text.

Set a Background Page Color

Set a Background Page Color

1 Within the <BODY> tag, type BGCOLOR=" ?".

Replace ? with a color name or hexadecimal value.

Note

For a table of 16 color codes you can apply, see the section "Change the Text Color."

The page appears in the Web browser with a background color assigned.

Note

To change the background using style sheets, see Chapter 11.

Set a Background Page Color

Add a Horizontal Line

You can add a solid line, or horizontal rule, across your page to separate blocks of information. Horizontal rules must occupy a line by themselves and cannot appear within a paragraph.

You can define the thickness and length of a horizontal line using the !SIZE and WIDTH attributes.

Add a Horizontal Line

Add a Horizontal Line

Add a Simple Line

1 Type <HR> where you want to insert a horizontal rule.

• The browser displays the line across the page.

Add a Horizontal Line

SET A LINE THICKNESS AND WIDTH

1 Within the <HR> tag, type SIZE=" ?", replacing ? with the thickness you want to assign, measured in pixels.

2 Within the <HR> tag, type WIDTH=" ?%", replacing ? with the percentage of the page you want the rule to extend across.

You can also set a numeric value to set the width of the rule in pixels.

• The browser displays the line across the page.

Add a Horizontal Line

Tip

How do I make my line appear more solid?

By default, the browser displays horizontal rules with shading, giving the lines a three-dimensional effect. To remove the shading, add the NOSHADE attribute to your <HR> tag so that it reads <HR NOSHADE>.

Add a Horizontal Line

Can I add color to a horizontal line?

Yes. You can insert the COLOR attribute and assign a color value to a line. For example, if you type <HR COLOR="#0000FF">, the browser displays the line as blue. See the section "Change the Text Color" for more about HTML colors.

Add a Horizontal Line
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.95.216