码迷,mamicode.com
首页 > Web开发 > 详细

HTML连载23-属性选择器(上)

时间:2019-07-18 00:23:22      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:cto   alt   selector   attr   pre   根据   www   sele   attribute   

一、属性选择器

1.

(1)定义:根据指定的 属性名称找到对应的标签,然后设置属性

(2)格式:标签[属性=值]:{属性:值;]

注意:前一个值是不带引号的

(3)例子:

 

   <style>

        p[id]{

            color: red;

        }

</style>

</head>

<body>

<p id="identity1">我是段落1</p>

<p id="identity2">我是段落2</p>

<p id="identity3">我是段落3</p>

<p>我是段落3</p>

</body>

 

技术图片

解释:我们在p标签中找到带id属性(如果id属性值缺省那么我们就认为是全部的这种属性都是选中的)的,然后设置为红色

(4)场景:就是区分input属性

二、源码:

d79_attribute_selector.html

地址:

https://github.com/ruigege66/HTML_learning/blob/master/d79_attribute_selector.html

2.CSDN:https://blog.csdn.net/weixin_44630050(心悦君兮君不知-睿)

3.博客园:https://www.cnblogs.com/ruigege0000/

4.欢迎关注微信公众号:傅里叶变换,后台回复“礼包”获取Java大数据学习视频礼包

技术图片

HTML连载23-属性选择器(上)

标签:cto   alt   selector   attr   pre   根据   www   sele   attribute   

原文地址:https://www.cnblogs.com/ruigege0000/p/11204506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!