01:HTML中插入CSS(层叠样式表)的方法

1.注释:
(1).HTML的注释:
(2).CSS的注释:/* */


2.HTML中插入CSS(层叠样式表)的方法
(1).行内样式 (在标签后面直接写样式)

<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>行内样式</title>
</head>
<body>
    <p style="font-famliy:宋体; text-align:center;font-style:italic; text-transform:uppercase; font-size:22px;  text-decoration:underline; font-weight:bold; letter-spacing:13px">html中插入css样式的方法:</br>1 行内样式;2 内部样式; <br/>3 外部样式; 4 导入样式;</p>

</body>
</html>

(2)嵌入式(将样式和html语言分开写)

<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>行内样式</title>
   <style type="text/css">
   p{
    text-decoration:underline;
    text-align:center;
    font-size:26px;
    font-family:宋体;
    font-weight:bolder;
    text-transform:lowercase;
    letter-spacing:4px;
    color:pink;
    background-color:green;
   }

   </style>
</head>
<body>
    <p >HTML中插入CSS样式的方法:</br>
        1 行内样式;2 内部样式; <br/>
        3 外部样式; 4 导入样式;
    </p>

</body>
</html>

3.外部样式(链接式:将CSS和HTML分开写)!!!!最常用
first.html

<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>行内样式</title>
   <link href="first.css" type="text/css" rel="stylesheet">
</head>
<body>
    <p >HTML中插入CSS样式的方法:</br>
        1 行内样式;2 内部样式; <br/>
        3 外部样式; 4 导入样式;
    </p>

</body>
</html>

first.css

p{
    text-decoration:underline;/*加下划线*/
    text-transform:lowercase;/*大写字母全部小写*/
    text-align:center;/*居中*/
    font-size:23px;/*字体大小*/
    font-family:黑体;/*设置字体*/
    font-style:italic;/*设置字倾斜*/
    text-indent:3px;/*设置首行缩进*/
    color:red;/*设置字体颜色*/
    background-color:#ddd;/*设置背景颜色*/
    letter-spacing:4px;
}

4.导入式
first.html

<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>行内样式</title>

   <style type="text/css">
    @import url(first.css);
   </style>
</head>
<body>
    <p >HTML中插入CSS样式的方法:</br>
        1 行内样式;2 内部样式; <br/>
        3 外部样式; 4 导入样式;
    </p>

</body>
</html>

first.css

p{
    text-decoration:underline;/*加下划线*/
    text-transform:lowercase;/*大写字母全部小写*/
    text-align:center;/*居中*/
    font-size:33px;/*字体大小*/
    font-family:黑体;/*设置字体*/
    font-style:italic;/*设置字倾斜*/
    text-indent:3px;/*设置首行缩进*/
    color:red;/*设置字体颜色*/
    background-color:#ddd;/*设置背景颜色*/
    letter-spacing:4px;
}

                                                                                                                                    2018.8.9

猜你喜欢

转载自blog.csdn.net/fighting_0808/article/details/81543539