1.[屬性名] 選擇含有指定屬性的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p[title]{
color:red;
}
</style>
</head>
<body>
<p title="hello">求關注1</p>
<p title="helloWord">求關注2</p>
<p title="hiHello">求關注3</p>
<p>求關注4</p>
<p>求關注5</p>
<p>求關注6</p>
<p>求關注7</p>
</body>
</html>
2.[屬性名=屬性值] 選擇含有指定屬性和屬性值的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p[title=hello]{
color:red;
}
</style>
</head>
<body>
<p title="hello">求關注1</p>
<p title="helloWord">求關注2</p>
<p title="hiHello">求關注3</p>
<p title="hi">求關注4</p>
<p>求關注5</p>
<p>求關注6</p>
<p>求關注7</p>
</body>
</html>
3.[屬性名^=屬性值] 選擇屬性以指定值開頭的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p[title^=hello]{
color:red;
}
</style>
</head>
<body>
<p title="hello">求關注1</p>
<p title="helloWord">求關注2</p>
<p title="hiHello">求關注3</p>
<p title="hi">求關注4</p>
<p>求關注5</p>
<p>求關注6</p>
<p>求關注7</p>
</body>
</html>
4.[屬性名$=屬性值] 選擇屬性值以指定值結尾的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p[title $= hello]{
color:red;
}
</style>
</head>
<body>
<p title="hello">求關注1</p>
<p title="helloWord">求關注2</p>
<p title="hihello">求關注3</p>
<p title="hi">求關注4</p>
<p>求關注5</p>
<p>求關注6</p>
<p>求關注7</p>
</body>
</html>
5.[屬性名*=屬性值] 選擇屬性值中含有某元素的元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p[title *= hello]{
color:red;
}
</style>
</head>
<body>
<p title="hello">求關注1</p>
<p title="helloWord">求關注2</p>
<p title="hihello">求關注3</p>
<p title="hi">求關注4</p>
<p>求關注5</p>
<p>求關注6</p>
<p>求關注7</p>
</body>
</html>