【CSS】CCS引入的三种方式

目录

1、行内样式

2、内部样式表

3、外部样式表

4、使用 @import 引用外部 CSS 文件


1、行内样式

<p style="color:red; font-size:18px;">我的字体颜色为红色,大小为18像素</p>

2、内部样式表

<head>
    <style type="text/css">
        p 
        {
            color: red;
            font-size: 18px;
        }
    </style>
</head>

<body>
    <p>我的字体颜色是红色,大小为18像素。</p>
</body>

3、外部样式表

(1)链接式

<head>
    <link rel="stylesheet" type="text/css" href="css/style.css" /> 
</head>

<body>
    <p>我的字体颜色是红色,大小为18像素</p>
</body>

(2)导入式

<head>
    <style type="text/css">
        @import url("css/style.css");
    </style>
</head>

<body>
    <p>我的字体颜色是红色,大小为18像素</p>
</body>

※:导入式也可以用在CSS文件导入外部CSS文件,如下面的style1.css导入外部style2.css:

@import url("css/style2.css");

p
{
    color:red;
    font-size: 18px;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章