CSS style sheet of using CSS to change fonts

Source: Internet
Author: User
Tags define definition
css| style Sheet The fonts on the previous page are immutable and stay there silently. When DHTML (Dynamic Web page) appears, we have more ways to control the font. In general, the implementation core of dynamic fonts is CSS (cascading style sheets) plus JavaScript. With both of these techniques, fonts can make a lot of difference.

1.CSS defines the label element of a font

Font-family: Sets the font word family.

<span style= "font-family: Black body, Arial (GB)" > Ctr </span>

Font-sytle: Sets the font type.

<span style= "Font-style:normal" > Ctr </span>

Font-weight: Sets the character weight of the font.

<span style= "Font-weight:bold" > Ctr </span>

Font-size: Sets the font size.

<span style= "font-size:14pt" > Ctr </span>

Font-decoration: Modifies text fonts, such as underlined "underline".

<span style= "Text-decoration:underline" > Ctr </span>

For the above font settings, we can use a convenient method:

<span style= "Font:normal bold 14pt blackbody" > Ctr </span>

The order defined in style is: font-style,font-weight,font-size,font-family.

2.CSS defines the conflict between font and <font> definition fonts

For CSS definition font and <font> definition font, we should pay attention to the following problems, such as the following font settings:

<span style= "font-family: Song Body (KSC); Font-size:200pt "><font> Ctr </font></span>

The font size will be set by the FONT-SIZE:200PT definition. But if you add the size attribute to <font>, for example:

<span style= "font-family: Song Body (KSC); Font-size:200pt "><font size=" 5 "> Ctr </font></span>

At this point, the size of the font is set to the type, FONT-SIZE:200PT will not work. The same is true for other properties. If you don't need dynamic fonts, you use HTML4.0 <font> to define fonts, and when you need dynamic fonts, you need to use CSS and JAVASCRITP to define fonts and raise events.

3. Define CSS Font attribute class

In general, when we make dynamic fonts, we will first use CSS to define the entire properties of the page font, and then reference in the page, instead of each paragraph of text to set, this is the implementation of dynamic font first step.

<style type= "Text/css" >

. tt2 {font-family: "boldface"; font-size:16px font-style:normal; line-height:17px}

</style>

<body>

<p class= "Tt2" > Ctr </p>

</body>

In the above code, the "Ctr" two words refer to the font style defined by the. Main_2 class. Of course you can define different font styles in <style></style> so that the pages are referenced according to different fonts. Like what:

<style type= "Text/css" >

. tt1 {font-family: "XXFarEastFont-Arial"; font-size:15px font-style:normal;}

. tt2 {font-family: "boldface"; font-size:16px Font-style:normal;}

</style>

<body>

<p class= "Tt1" > Ctr </p>

<p class= "Tt2" > Ctr </p>

</body>



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.