| You are here: | About>Computing & Technology>Web Design / HTML> About.com Web Design A to Z> Web Design Articles A-H> Web Design/HTML Articles C> Changing Font Attributes |
![]() | Web Design / HTML |
Changing Font AttributesLearn to Use CSS to Change Font AttributesFonts and CSSThe font tag has been deprecated in favor of cascading style sheets, so it is a good idea to get familiar with how to change the font color, size, and face with CSS. The one advantage is that working with CSS, you have much more control over the look of the font, including size in pixels and other aspects of typesetting. Font properties in CSS are one of the most common ways to make your page more distinctive and unique. It is easy to change the color, size, and even face (the font itself) of your text with CSS font properties.
There are three basic parts to a font:
Font ColorsTo change the color of the text, simply use the CSS color style property. You can use either color names or hexadecimal codes. As with all color on the Web, it is best to use browser safe colors. Try the following styles in your Web pages: <span style="color: #ff0000;">this font is colored red</span> Colorizing the Web Font SizesWhen you set the font size on the Web you can set it in relative sizes or be very specific using pixels, centimeters or inches. However, the more exact font sizes are meant to be used for print and not for Web pages, where everyone who views your Web site might have a different resolution, monitor size, or default font setting. Thus, if you choose 15px as your standard size, you might be unpleasantly surprised to see how large or small your font renders to your customers. I recommend you use ems. Ems allow your page to remain accessible no matter who is viewing it, and ems are meant for screen rendering. Leave your pixels and points for print rendering. To change your font size, put the following style in your Web page: <span style="font-size: 1em;">this font is 1em</span> Deciding on Font Sizing in CSS Font FacesThe face of your font is the actual font that is used. You can declare any font that you would like, but remember, if your reader doesn't have that font installed their browser will try to find a match for it, and their page will not look like you intended. To address this problem you can specify a list of face names, separated by commas, for the browser to use in order of preference. Keep in mind that a standard font on a PC (such as Arial) might not be standard on a Macintosh. So you should always view your pages with a minimally installed machine (and preferably on both platforms) to make sure that your page looks as designed even with minimal fonts. One of my favorite font sets is <span style="font-family: arial, geneva, helvetica, helv, sans-serif;"> This set is a sans-serif font collection and while geneva and arial do not look terribly similar, they are both fairly standard on Macintosh and Windows computers. I include helvetica and helv for customers on other operating systems such as Unix or Linux that might not have a robust font library. <span style="font-family: geneva, arial, helvetica, sans-serif;">this font is sans-serif</span> Font ResourcesFonts and Typography in Web Design |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


