css 选择器

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
/* (1)类型选择器 */
p,h1 {
	color: red;
	font-weight: bold;
}

/* (2)后代选择器 */
ol li {
	color: blue;
}

/* (3)ID选择器 */
#myInput {
	color: red;
}

/* (4)class选择器 */
.myButton {
	color: blue;
}

/* (5)伪类选择器 */
a:LINK {
	color: red;
}
a:VISITED {
	color: olive;
}
a:ACTIVE {
	color: blue;
}

/* (6)通用选择器*/

/* ---------
* {
	padding: 0;
	margin: 0;
}
--------- */

/* (7)子选择器 */
#nav>li {
	padding-left: 20px;
}

</style>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello U</title>
</head>
<body>
	<h1>This is tag h1.</h1>
	<p>This is tag p.</p>
	<ol>
		<li>This is tag li 1 in ol.</li>
		<li>This is tag li 2 in ol.</li>
	</ol>
	<ul>
		<li>This is tag li 3 in ul.</li>
		<li>This is tag li 4 in ul.</li>
	</ul>
	
	<input id="myInput" type="text" value="input1"/>
	<input class="myButton" type="button" value="button1" />
	
	<p/>
	<a href="http://www.baidu.com">baidu</a>
	
	<p/>
	<ul id="nav">
		<li>Home</li>
		<li>Service</li>
		<ul>
			<li>Home</li>
			<li>Service</li>
		</ul>
		<li>Contact Us</li>
	</ul>
	
</body>
</html>
 css层叠:

(1)用style属性编写的规则高于其他任何规则。

(2)Id选择器高于没有ID选择器的规则。

(3)类选择器的规则比只有类型选择器的规则特殊。

(4)如归两个规则的特殊性相同,那么后面定义的规则优先。

 

css引入页面:

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

<style type="text/css">

<!-- 

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

-->

</style>

 

css引入速度

css注释、空格的删除以及压缩

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值