CSS Fonts
The foundational CSS Fonts provides cross-browser typographical normalization and control while still allowing users to choose and adjust their font size. Both Standards and Quirks modes are supported in A-grade browsers.
Note: CSS Base can compliment CSS Reset by applying a style foundation for common HTML elements that is consistent for A-grade browsers.
More Information
- Examples: CSS Fonts in action.
- Download: CSS Fonts as part of the full YUI Library.
- Free Hosting on our fast edge servers with combo-loading.
- License: BSD.
Getting Started
Include Dependencies
To use CSS Fonts, include the following source file in your web page with the link element:
Global vs. Contextual
YUI's CSS resources apply rules to HTML elements directly (using type selectors). An alternate version of the resource is available that target elements by context only. This contextual -context.css version selects HTML elements only when they descend from the .yui-fonts classname.
Here is how to include the contextual version of CSS Fonts:
Using CSS Fonts
This section describes the features of CSS Fonts and includes these sections:
Default Text
With the CSS linked into the page, all text renders in the Arial font, at 13 pixel size, with 16 pixel line-height. The pre and code elements use the "monospace" font-family. Here's an example of HTML elements after Fonts has been applied.
Font-size Adjustment
To change the size of a font, use a percentage value from the chart below. Always use percentages as the units because they render more consistently than ems, and because they allow user-initiated resizing (unlike pixels). See the example.
| For pixels (px) | Declare this percent (%) |
|---|---|
| 10 | 77 |
| 11 | 85 |
| 12 | 93 |
| 13 | 100 |
| 14 | 108 |
| 15 | 116 |
| 16 | 123.1 |
| 17 | 131 |
| 18 | 138.5 |
| 19 | 146.5 |
| 20 | 153.9 |
| 21 | 161.6 |
| 22 | 167 |
| 23 | 174 |
| 24 | 182 |
| 25 | 189 |
| 26 | 197 |
Font-family Adjustment
Arial is the default font-family for all text (except pre and code) when you use Fonts CSS. Specify a new font-family when you want something other than Arial. See the example.
Using CSS Fonts In Specific Contexts
If you're using the contextual version, CSS Fonts's rules are only applied to elements that descend from a node with a class value of .yui-fonts. The classname can go as high in the DOM tree as desired, including on the <HTML&ht; element directly.
The following code snippet show how you might apply CSS Fonts to one of two columns:
Here is an example showing how to apply CSS Fonts to a subset of a page.
Support & Community
Forum & Blog
There is a dedicated mailing list for YUI 3. Click the link to visit the list, or use the form below to subscribe:
You might also be interested in the general YUI list: ydn-javascript.
In addition, please visit the YUIBlog for updates and articles about the YUI Library written by the library's developers.
Filing Bugs & Feature Requests
The YUI Library's public bug tracking and feature request repositories are located on the YUILibrary.com site. Before filing new feature requests or bug reports, please review our reporting guidelines.
