(48) CSS (Web Fonts)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Using The Font You Want

In the @font-face rule; first define a name for the font (e.g. myFirstFont) and then point to the font file. Tip: Always use lowercase letters for the font URL. Uppercase letters can give unexpected results in IE. To use the font for an HTML element, refer to the name of the font (myFirstFont) through the font-family property: <!DOCTYPE html> <html> <head> <style> @font-face { font-family: myFirstFont; src: url(sansation_light.woff); } * { font-family: myFirstFont; } </style> </head> <body> <h1>The @font-face Rule</h1> <div> With CSS, websites can use fonts other than the pre-selected "web-safe" fonts. </div> <p><b>Note:</b> Internet Explorer 8 and earlier, do not support the @font-face rule.</p> </body> </html>

CSS Font Descriptors

The following table lists all the font descriptors that can be defined inside the @font-face rule: Descriptor Values Description font-family name Required. Defines a name for the font src URL Required. Defines the URL of the font file font-stretch normal condensed ultra-condensed extra-condensed semi-condensed expanded semi-expanded extra-expanded ultra-expanded Optional. Defines how the font should be stretched. Default is "normal" font-style normal italic oblique Optional. Defines how the font should be styled. Default is "normal" font-weight normal bold 100 200 300 400 500 600 700 800 900 Optional. Defines the boldness of the font. Default is "normal" unicode-range unicode-range Optional. Defines the range of UNICODE characters the font supports. Default is "U+0-10FFFF"

Different Font Formats

TrueType Fonts (TTF) TrueType is a font standard developed in the late 1980s, by Apple and Microsoft. TrueType is the most common font format for both the Mac OS and Microsoft Windows operating systems. OpenType Fonts (OTF) OpenType is a format for scalable computer fonts. It was built on TrueType, and is a registered trademark of Microsoft. OpenType fonts are used commonly today on the major computer platforms. The Web Open Font Format (WOFF) WOFF is a font format for use in web pages. It was developed in 2009, and is now a W3C Recommendation. WOFF is essentially OpenType or TrueType with compression and additional metadata. The goal is to support font distribution from a server to a client over a network with bandwidth constraints. The Web Open Font Format (WOFF 2.0) TrueType/OpenType font that provides better compression than WOFF 1.0. SVG Fonts/Shapes SVG fonts allow SVG to be used as glyphs when displaying text. The SVG 1.1 specification define a font module that allows the creation of fonts within an SVG document. You can also apply CSS to SVG documents, and the @font-face rule can be applied to text in SVG documents. Embedded OpenType Fonts (EOT) EOT fonts are a compact form of OpenType fonts designed by Microsoft for use as embedded fonts on web pages.

The CSS @font-face Rule

Web fonts allow Web designers to use fonts that are not installed on the user's computer. When you have found/bought the font you wish to use, just include the font file on your web server, and it will be automatically downloaded to the user when needed. Your "own" fonts are defined within the CSS @font-face rule.

Using Bold Text

You must add another @font-face rule containing descriptors for bold text: <!DOCTYPE html> <html> <head> <style> @font-face { font-family: myFirstFont; src: url(sansation_light.woff); } @font-face { font-family: myFirstFont; src: url(sansation_bold.woff); font-weight: bold; } * { font-family: myFirstFont; } </style> </head> <body> <h1>The @font-face Rule</h1> <div> With CSS, websites can use <b>fonts other than the pre-selected "web-safe" fonts</b>. </div> <p><b>Note:</b> Internet Explorer 8 and earlier, do not support the @font-face rule.</p> </body> </html> The file "sansation_bold.woff" is another font file, that contains the bold characters for the Sansation font. Browsers will use this whenever a piece of text with the font-family "myFirstFont" should render as bold. This way you can have many @font-face rules for the same font.


Kaugnay na mga set ng pag-aaral

Social Media Marketing Chapter 3

View Set

Listening Guide Quiz 17: Haydn: Trumpet Concerto

View Set

Medical Laboratory Science Review- Harr - Immunology

View Set

Algebra Module 3 linear equations

View Set

US History: Q3 - Lesson 4 - Assigment 8_Industrial Lifestyle: Trends

View Set

A Porra do Cursinho Inteiro (6 de Junho - 30 de Agosto)

View Set