CSS引入样式

一、内联样式,style属性

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>CSS学习</title>
</head>
<body>
	<p style="color:#FF0000; font-size:20px; text-decoration:underline;">第一段</p>
	<p style="color:#000000; font-style:italic;">第二段</p>
	<p style="color:#FF00FF; font-size:25px; font-weight:bold;">第三段</p>
</body>
</html>
二、内嵌样式,嵌入在head中

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>CSS学习</title>
<style type="text/css">
p{
	color:#FF00FF;
	text-decoration:underline;
	font-weight:bold;
	font-size:25px;
}
</style>
</head>
<body>
	<p>第一段</p>
	<p>第二段</p>
	<p>第三段</p>
</body>
</html>
三、 引入外部样式:link

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>CSS学习</title>
<link rel="stylesheet" type="text/css" href="CSS/1.css">
</head>
<body>
	<h2>CSS标题1</h2>
	<p>段落</p>
	<h2>CSS标题2</h2>
	<p>段落2</p>
</body>
</html>
通过右键->properties查看index.jsp路径为:D:\workspace\first\WebRoot\index.jsp,1.css路径为:D:\workspace\first\WebRoot\CSS\1.css

注意:CSS文件夹放在WEB-INF文件夹下识别不了,放在IMA-G文件夹下也识别不了,但是ima-g路径下能识别,难道路径不能为大写字母加-?还是电脑问题?

四、导入外部样式文件import

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>CSS学习</title>
<style type="text/css">
@import "CSS/1.css"
</style>
</head>
<body>
	<h2>CSS标题1</h2>
	<p>段落</p>
	<h2>CSS标题2</h2>
	<p>段落2</p>
</body>
</html>

五、 各种方式优先级

内联>内嵌>外部导入>外部链接





  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值