Login | Register | FAQ Anonymous * Home * Tutorials * Forums * About ____________________ Search Home » Tutorials » CSS » Lesson 4: Fonts Lesson 4: Fonts In this lesson you will learn about fonts and how they are applied using CSS. We will also look at how to work around the issue that specific fonts chosen for a website can only be seen if the font is installed on the PC used to access the website. The following CSS properties will be described: * font-family * font-style * font-variant * font-weight * font-size * font Font family [font-family] The property font-family is used to set a prioritized list of fonts to be used to display a given element or web page. If the first font on the list is not installed on the computer used to access the site, the next font on the list will be tried until a suitable font is found. There are two types of names used to categorize fonts: family-names and generic families. The two terms are explained below. Family-name Examples of a family-name (often known as "font") can e.g. be "Arial", "Times New Roman" or "Tahoma". Generic family Generic families can best be described as groups of family-names with uniformed appearances. An example is sans-serif, which is a collection of fonts without "feet". The difference can also be illustrated like this: Three examples of generic families and some of their family members When you list fonts for your web site, you naturally start with the most preferred font followed by some alternative fonts. It is recommended to complete the list with a generic font family. That way at least the page will be shown using a font of the same family if none of the specified fonts are available. An example of a prioritized list of fonts could look like this: h1 {font-family: arial, verdana, sans-serif;} h2 {font-family: "Times New Roman", serif;} * Show example Headlines marked with
: p { font-style: italic; font-weight: bold; font-size: 30px; font-family: arial, sans-serif; } Using the short hand property, the code can be simplified: p { font: italic bold 30px arial, sans-serif; } The order of values for font is: font-style | font-variant | font-weight | font-size | font-family Summary You have now learned about some of the possibilities related to fonts. Remember that one of the major advantages of using CSS to specify fonts is that at any given time, you can change font on an entire website in just a few minutes. CSS saves time and makes your life easier. In the next lesson we will look at text. __________________________________________________________________ Related topics in the CSS Forum Replies Views Font issues 3 1364 Wrapping text around images not working 3 2769 wrap text around div 1 2347 My text color changed when clicked on in browser 2 2202 Brand New to code, font color not working 1 2321 + Post a new topic __________________________________________________________________ << Lesson 3: Colors and backgrounds Lesson 5: Text >> Tutorials * HTML Tutorial * CSS Tutorial + Introduction + What is CSS? + How does CSS work? + Colors and backgrounds + Fonts + Text + Links + Identification and grouping of elements (class and id) + Grouping of elements (span and div) + The box model + Margin and padding + Borders + Height and width + Floating elements (floats) + Positioning of elements + Layer on layer with z-index (Layers) + Web-standards and validation * PHP Tutorial * ASP Tutorial * JavaScript Tutorial Language [English___________] >> Layout [Default_______] >> __________________________________________________________________ Who is online: In total there are 336 users online :: 4 registered, 0 hidden and 332 guests Most users ever online was 819 on Mon Oct 15, 2012 9:42 am Registered users: Exabot [Bot], Google [Bot], Google Adsense [Bot], Google Feedfetcher Statistics: Total posts 9987 - Total topics 4189 Total members 10321 - Our newest member stumpht View complete list of members Language: العربية | Deutsch | English | Español | Français | עברית | Italiano | Polski | Portgués (Brasil) | Русский | 中文 |