[属性名] 选择含有指定属性的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>属性选择器</title>
<style>
p[title]{
color:red;
}
</style>
</head>
<body>
<p title="abc">11111111111</p>
<p title="abcdef">22222222222</p>
<p title="helloabc">33333333333</p>
<p>44444444444</p>
<p>55555555555</p>
</body>
</html>
[属性名=属性值] 选择含有指定属性和属性值的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>属性选择器</title>
<style>
p[title=abc]{
color:red;
}
</style>
</head>
<body>
<p title="abc">11111111111</p>
<p title="abcdef">22222222222</p>
<p title="helloabc">33333333333</p>
<p>44444444444</p>
<p>55555555555</p>
</body>
</html>
[属性名^=属性值] 选择属性值以指定值开头的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>属性选择器</title>
<style>
p[title^=abc]{
color:red;
}
</style>
</head>
<body>
<p title="abc">11111111111</p>
<p title="abcdef">22222222222</p>
<p title="helloabc">33333333333</p>
<p>44444444444</p>
<p>55555555555</p>
</body>
</html>
[属性名$=属性值] 选择属性值以指定值结尾的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>属性选择器</title>
<style>
p[title$=abc]{
color:red;
}
</style>
</head>
<body>
<p title="abc">11111111111</p>
<p title="abcdef">22222222222</p>
<p title="helloabc">33333333333</p>
<p>44444444444</p>
<p>55555555555</p>
</body>
</html>
[属性名=属性值]* 选择属性值中含有某值的元素的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>属性选择器</title>
<style>
p[title*=abc]{
color:red;
}
</style>
</head>
<body>
<p title="abc">11111111111</p>
<p title="abcdef">22222222222</p>
<p title="helloabc">33333333333</p>
<p>44444444444</p>
<p>55555555555</p>
</body>
</html>