CSS字体Font属性

CSS字体属性可定义文字所使用的字体。
设置文字的字体

实例:

代码
<html>
<head>
<style type="text/css">
h3
{font-family: times}
h5
{font-family: arial}
p
{font-family: courier}
p.sansserif
{font-family: sans-serif}
</style>
</head>
<body>
<h3>This is header 3</h3>
<h5>www.jz006.com</h5>
<p>This is a paragraph</p>
<p class="sansserif">This is a paragraph</p>
</body>
</html>

设置字体的大小

实例:

代码
<html>
<head>
<style type="text/css">
h1
{font-size: 150%}
h2
{font-size: 130%}
p
{font-size: 100%}
</style>
</head>
<body>
<h1>This is header 1 www.jz006.com</h1>
<h2>This is header 2</h2>
<p>This is a paragraph</p>
</body>
</html>

设置字体的款式

实例:

代码
<html>
<head>
<style type="text/css">
h1
{font-style: italic}
h2
{font-style: normal}
p
{font-style: oblique}
</style>
</head>
<body>
<h1>This is header 1</h1>
<h2>This is header 2 www.jz006.com</h2>
<p>This is a paragraph</p>
</body>

 

设置字体的形态

实例:

代码
<html>
<head>
<style type="text/css">
p.normal
{font-variant: normal}
p.small
{font-variant: small-caps}
</style>
</head>
<body>
<p class="normal">This is a paragraph www.jz006.com</p>
<p class="small">This is a paragraph</p>
</body>
</html>

设置字体粗细

实例:

代码
<style type="text/css">
p.normal
{font-weight: normal}
p.thick
{font-weight: bold}
p.thicker
{font-weight: 900}
</style>
</head>
<body>
<p class="normal">This is a paragraph</p>
<p class="thick">This is a paragraph www.jz006.com</p>
<p class="thicker">This is a paragraph</p>
</body>
</html>

一个声明设置一切字体属性

实例:

<html>
<head>
<style type="text/css">
p
{
font
: italic small-caps 900 12px arial
}
</style>
</head>
<body>
<p>This is a paragraph <br />
www.jz006.com
</p>
</body>
</html>

 

posted on 2010-05-08 23:13  pwm_1987  阅读(201)  评论(0编辑  收藏  举报

导航