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 for the font
font-family: Sets the font word family.
The code is as follows |
Copy Code |
<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:
The code is as follows |
Copy Code |
<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:
The code is as follows |
Copy Code |
<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:
The code is as follows |
Copy Code |
<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.
code is as follows |
copy code |
<style type= "Text/css" > . tt2 {font-family: "bold"; font-size:16px; font-style:normal; li NE-HEIGHT:17PX} </style> |