通过元素属性名修改元素的样式
<style> .p1{ word-spacing: 20px; } [title='one']{ color: red; } [title*="one"]{ color: red; } [title*=one]{ color: red; } </style><body> <div> <p title="one" class="p1">你好</p> <p class="p1" title="two-one">hell app</p> <p class="p1" title="twoone">hell app</p> <p class="p1" title="onetwo">hell app</p> </div>如上,p标签都包含title属性
通过style中的[title]{color:red}修改包含有title属性的元素
1.[title]{
color: red;
}
修改包含有title属性的标签
2.[title='one']{
color: red;
}
其中[title='one']可以是[title="one"],[title=one]
修改包含有title,且title属性值恰好等于one的所有元素
3.[title*="one"]{
color: red;
}
修改包含有title,且title中包含one的所有元素
4.[title^=one]{
color: red;
}
修改title中以one开头的元素
5.[title|=one]{
color: red;
}
title属性值恰好等于one或者以one开头且后面紧跟连字符-的元素
6.[title~=one]{
color: red;
}
title属性包含单词one的元素(one单词与其他单词之间必须用空格隔开)
7.[title$=one]{
color: red;
}
title属性以one结尾的元素