初识css

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>唯唯同学知识分享</title>
		<!-- css使用方式
		 1.通过style标签设置样式
		 2.通过style属性设置样式
		 3.通过css文件使用
		 
		 注意:css的特点
		 1.直接在style上写的内容优先级最高,同样的选择器,谁在后面谁的优先级比较高.
		  2.选择器的优先级,在其余情况下相同下,继承的样式<浏览器模式的样式<标签样式<class样式<id样式<style样式
		  3.可以使用在属性后面使用 !important 将属性优先级提升到最大.注:不要过度使用!important
		  4.越复杂具体的选择器,优先级越高
		 -->
		 
		 
		 <!-- 通过css文件使用 -->
		 <link rel="stylesheet" type="text/css" href="css/style.css"/>
		 <!-- 通过style标签设置样式 -->
		 <style type="text/css">
		 	#d1{
				color: skyblue;
				font-size: 50px;
			}
			.d1{
				color: blue;
				font-size: 50px;
			}
			div{
				color: yellowgreen;/*添加在yellowgreen的后面!important*/
				font-size: 50px;
			}
			#d2{
				color: thistle;
				font-size: 50px;
			}
		 </style>
	</head>
	<body>
		<div id="d1" class="d1">
			helloworld 1
		</div>
		
		<!-- 通过style属性设置样式 -->
		<div  style="color: hotpink; font-size: 50px;">
			helloworld 2
		</div>
		
		<div id="d2">helloworld 3</div>
	</body>
</html>

css优先级

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值