CMS

Content

HTML

Images

Monetizing

Home » HTML

Changing Text Size, Text Color & Font Face

Monday, 22 March 2010 · Print This Post Print This Post One Comment

Related Reading

This entry is part 5 of 5 in the series Basic Text Formatting

In this lesson of our free online web design course, we are going to add more flavor to our text by changing its color, size and font type. To do that, we’re going to use the <font> tag along with “size”, “color” and “face” attributes.

Copy and paste the below HTML code into your notepad:

<html>
<head>

</head>
<body>

<font color=”red” size=”5″ face=”arial”>

This is a red text with a size of 5, written in the “Arial” font.

</font>

</body>
</html>

As our text indicates, we have created a red text with a size of 5, written in the “Arial” font by using the <font> tag and the “color”, “size” and “face” attributes. Now, save your file as HTML and double-click it to open in your web browser. You should get the below output:

This is a red text with a size of 5, written in the “Arial” font.

The font tag has only these three attributes – color, size and face. Color can be anything from black to white. You can use the name, or the color hex code (i.e. #FF0000,#559A2E, etc.) to indicate the color. The size can vary from 1 to 7, where 1 is the smallest and 7 is the biggest.

A Word About Font Faces

Font types (i.e. font “faces”) are a bit of a grey area – there is a huge number of font faces on the internet, but very few of them can be used effectively; as most font faces can not be found on most end-users’ machines. That means, if you use the rare face “Aircut” in your site, many people won’t be able to view your site like you do, as they probably do not have the “Aircut” face installed on their computers. To negate this, you can define more than one font face (i.e. substitute font faces) for your text by separating them with a comma. For example you can use <font face=”aircut,arial”> and the end user’s browser will first look for the font face “Aircut”, and if that face is not available, it will use “Arial” instead. The most commonly used font faces are: Times New Roman, Arial, Verdana, Courier, Mono, Serif and Sans-Serif. I generally prefer “Verdana”.

Setting Attributes Of The <Font> Tag

Now that we’ve talked about font faces, let’s resume our free online web design course by delving deeper into setting the attributes of the <font> tag.

When writing a <font> tag, you don’t need to include all three attributes. You can use the <font> tag even if you only want to change the color of a certain text and not the size or the font face, for example. For that you need to include only the “color” attribute:

<html>
<head>

</head>
<body>

<font color=”red”>
Red Text
</font>

<br><br>

<font color=”blue”>
Blue Text
</font>

<br><br>

<font color=”green”>
Green Text
</font>

</body>
</html>

The output is:

Red Text

Blue Text

Green Text

Or you might wish to change the size of a certain text. For that you ought to use only the “size” attribute of the <font> tag:

<html>
<head>

</head>
<body>

<font size=”2″>
Small Text
</font>

<br><br>

<font size=”4″>
Medium Text
</font>

<br><br>

<font size=”7″>
Big Text
</font>

</body>
</html>

In this case, our output would be:

Small Text

Medium Text

Big Text

Or maybe, you want to change the font face of your text. For that purpose, you can use the “face” attribute alone:

<html>
<head>

</head>
<body>

<font face=”verdana”>
Text In Verdana
</font>

<br><br>

<font face=”arial”>
Text In Arial
</font>

<br><br>

<font face=”times new roman”>
Text In Times New Roman
</font>

</body>
</html>

And we have this output:

Text In Verdana

Text In Arial

Text In Times New Roman

You can also use two attributes at the same time:

<html>
<head>

</head>
<body>

<font face=”verdana” size=”5″>
Big Text In Verdana
</font>

</body>
</html>

To get an output like this:

Big Text In Verdana

Anyway, I am sure you get my point… :)

If you enjoyed this lesson, please link to it :)

Our basic text formatting lesson is over. Proceed to the next lesson of online web design course to learn about web colors and color hex codes.

Series Navigation«Creating Ordered & Unordered Lists

Bookmark this Post Subscribe to Blog

Popular Tags

Adsense Background Cascading Style Sheets colors Content font Forms GIF Hex Codes HTML Hyperlinking Images IMeye JavaScript JPEG Keyword Research layout Merging meta PNG SEO Sizing spacer Tables text W3C
Comments
Leave a Comment

Threaded commenting powered by Spectacu.la code.