HTML+CSS_05-CSS常用文本样式

本文详细介绍了CSS中用于设置文本样式的各项属性,包括颜色、大小、字体、倾斜、加粗、行高、下划线及首行缩进等。通过具体示例展示了如何在div和em元素中应用这些样式。

css 文本设置

 

  • color 设置文字的颜色 color:red;

  • font-size 设置文字的大小 font-size:12px;

  • font-famaily 设置文字的字体 font-family:'Microsot Yahei';

  • font-style 设置文字是否倾斜 font-style:"normal"; 不倾斜 font-style:'italic'; 倾斜

  • font-weight 设置文字是否加粗 font-weight:bold; 加粗 font-w:normal; 不加粗

  • line-height 设置文字的行高 上下同时增加高度 line-height:24px;

  • font 同时设置几个属性 顺序为 font:是否加粗 字号/行高 字体;  font:normal 12px/36px '微软雅黑'

  • tex-decoration 设置文字下划线 tex-decoration:none 将文字下划线去掉

  • text-indent 设置文字首行缩进 text-indent:24px 设置文字爱首行缩进24px

 

 

div 和 em 里面的内容使用不同的格式定义

 

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>test_style</title>

    <style type="text/css">

 

        div{

            font-size:20px;

            color:green;

            font-family:'Microsoft Yahei';

        }

 

        em{

            font-size:30px;

            color:red;

            font-style:normal;

            font-family:'Microsoft Yahei';

        }

    </style>

</head>

<body>

    <div>

        The secret of success is constancy of purpose.

    </div>

 

    <em>

        Work makes the workman.

    </em>

</body>

</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值