CSS 属性 选择器

CSS 教程 · 2019-02-28 22:29:17

具有特定属性的HTML元素样式

具有特定属性的HTML元素样式不仅仅是class和id。

注意:IE7和IE8需声明!DOCTYPE才支持属性选择器!IE6和更低的版本不支持属性选择器。

属性选择器

下面的例子是把包含标题(title)的所有元素变为蓝色:

实例

[title] { color:blue; }

属性和值选择器

下面的实例改变了标题title='codercto'元素的边框样式:

实例

[title=codercto] { border:5px solid green; }

属性和值的选择器 - 多值

下面是包含指定值的title属性的元素样式的例子,使用(~)分隔属性和值:

实例

[title~=hello] { color:blue; }

下面是包含指定值的lang属性的元素样式的例子,使用(|)分隔属性和值:

实例

[lang|=en] { color:blue; }

表单样式

属性选择器样式无需使用class或id的形式:

实例

input[type="text"] { width:150px; display:block; margin-bottom:10px; background-color:yellow; } input[type="button"] { width:120px; margin-left:35px; display:block; }

点击查看所有 CSS 教程 文章: https://www.codercto.com/courses/l/23.html

查看所有标签

Speed Up Your Site

Speed Up Your Site

Andrew B. King / New Riders Press / 2003-01-14 / USD 39.99

There's a time bomb on the web: user patience. It starts ticking each time someone opens one of your pages. You only have a few seconds to get compelling content onto the screen. Fail, and you can kis......一起来看看 《Speed Up Your Site》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具