css基础

在HTML中使用CSS的方法

行内样式

<p style="color:#FF0000";font-size:20px;text-decoration:underline;">正文内容1</p>

链接式

创建一个以css为后缀的文件

h2{
    color:#000FF;
}
p{
    color:#FF0000;
    text-decoration:underline;
    font-weight:bold;
    font-size:15px;
}

导入html文件中

<html>
<head>
    <title>页面标题</title>
    <style>
        @import url (test1.css);
    </style>
</head>
<body>
</body>
</html>

内嵌式

<html>
<head>
    <titke>页面标题</title>
    <style>
        p{
            color:#0000FF;
            text-decoration:underline;
          }
    </style>
</head>
<body>
</body>
</html>

优先级:行内样式>内嵌样式>导入样式

选择器

标记选择器

以 html 标签作为 css 修饰所用的选择器。

<style>
    h1{
        color:red;
        font-size:25px;
    }
</style>

class选择器

用于描述单一标签的样式。类选择器名称以一个点“.”号显示。

<style>
    .red{
        color:red;
        font-size:18px;
        }
    .green{
        color;green;
        font-size:20px;
        }
</style>

id选择器

id选择器可以为标有特定id的HTML元素制定特定的样式。

<style>
    #bold{
        font-weight:bold;
        }
</style>

span标签

<span></span>标注行/标签内元素

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不要熬夜的打工人!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值