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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值