css selector-attr

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>selector-attr.html</title>
	
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<!-- 属性选择器可以根据元素的属性及属性值来选择元素。 也可作用于class属性。
		[attribute] 		用于选取带有指定属性的元素。 
		[attribute=value] 	用于选取带有指定属性和值的元素。 
		[attribute~=value] 	用于选取属性值中包含指定词汇的元素。 
		[attribute|=value] 	用于选取带有以指定值开头的属性值的元素,该值必须是整个单词。 
		[attribute^=value] 	匹配属性值以指定值开头的每个元素。 
		[attribute$=value] 	匹配属性值以指定值结尾的每个元素。 
		[attribute*=value] 	匹配属性值中包含指定值的每个元素。 		
		
		属性选择器在为不带有 class 或 id 的表单设置样式时特别有用:
		input[type="text"] {
		  width:150px;
		  display:block;
		  margin-bottom:10px;
		  background-color:yellow;
		  font-family: Verdana, Arial;
		}

		input[type="button"] {
		  width:120px;
		  margin-left:35px;
		  display:block;
		  font-family: Verdana, Arial;
		}
	 -->
	<style type="text/css">
	[title] {
		color:red;
	}
	
	a[href*="w3school.com.cn"] {
		color: red;
	}
	
	[lang|=en] {
		color:red;
	}
	</style>
  </head>
  
  <body>
  
	<h1>可以应用样式:</h1>
	<a href="http://w3school.com.cn">W3School</a>	
	<h1>无法应用样式:</h1>
	<a name="w3school">W3School</a>
	
	<hr />
	
	<h1>可以应用样式:</h1>
	<a href="http://www.w3school.com.cn/">W3School</a>
	<a href="http://www.w3school.com.cn/css/">CSS</a>
	<a href="http://www.w3school.com.cn/html/">HTML</a>
	<h1>无法应用样式:</h1>
	<a href="http://www.w3c.org/">W3C</a>
	<a href="http://www.microsoft.com">Microsoft</a>
	<a href="http://www.apple.com.cn">Apple</a>

	<hr />
	
	<h1>可以应用样式:</h1>
	<p lang="en">Hello!</p>
	<p lang="en-us">Hi!</p>
	<h1>无法应用样式:</h1>
	<p lang="us">Hi!</p>
	<p lang="zh">Hao!</p>
  </body>
</html>

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值