Use CSS to customize webpage Fonts

Source: Internet
Author: User

How can I use a Custom font? The general solution is to convert the text into an image, but it is a little troublesome. It is not suitable for the lazy person, and it is not convenient to modify the image. Another type is defined by CSS styles. I chose this type because it is easy to use. In CSS, the @ font-face attribute is used to embed any font in the webpage, A slightly more complicated problem is that each browser has its own font format requirements.

. TTF or. OTF is applicable to Firefox 3.5, Safari, and Opera.
. EOT applies to Internet Explorer 4.0 +
. SVG for Chrome and IPhone

Method:

Stylesheet.css defines the style (that is, the Custom font part ),

@ Font-face {

Font-family: 'fontname';/* font name, which can be customized */

Src: url ('fontname. eot ');

Src: local ('fontname Regular '),

Local ('fontname '),

Url ('fontname. woff') format ('woff '),

Url ('fontname. ttf') format ('truetype '),

Url ('fontname. svg # fontname') format ('svg ');

}

Copy the content to your style sheet (note that the URL part matches the path of the font file in your own domain space)

/* Usage */

<P style = "font-family: fontName"> hello world! </P>

This is basically done.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.