使用 CSS 选择器选择具有 alt 属性的所有元素
要选择带有属性的元素,请使用 CSS [attribute] 选择器。
例如,alt 属性或 target 属性等。
您可以尝试运行以下代码来实现 CSS[attribute] 选择器,
示例
<!DOCTYPE html>
<html>
<head>
<style>
img[alt] {
border: 3px solid orange;
}
</style>
</head>
<body>
<img src = "https://tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg" height = "200" width = "200">
<img src = "https://tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg" height = "200" width = "200" alt = "Tutorials Library">
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP