css属性选择器语法:
<code>[attribute=value] 如:[target=-blank] /*选择所有使用target="-blank"的元素*/ 或 [attribute~=value] 如:[title~=flower] /*选择标题属性包含单词"flower"的所有元素*/ 或 [attribute|=language] 如:[lang|=en] /*选择一个lang属性的起始值="EN"的所有元素*/</code>
css属性选择器实例一:
选择所有使用target="_blank"的a元素
<code class="language-html"> <style> a[target=_blank] { background-color:yellow; } </style> <p>The link with target="_blank" gets a yellow background:</p> <a href="http://www.manongjc.com">manongjc.com</a> <a href="http://www.disney.com" target="_blank">disney.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> <p><b>Note:</b> For [<i>attribute</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p> </code>
在线运行
css属性选择器实例二:
选择标题属性包含单词"flower"的所有元素
<code class="language-html"> <style> [title~=flower] { border:5px solid yellow; } </style> <p>The image with the title attribute containing the word "flower" gets a yellow border.</p> <img src="/static/imghwm/default1.png" data-src="/images/online_demo/klematis.jpg" class="lazy" title="klematis flower" alt="css 属性选择器 - 根据html元素的name属性值选择改元素" > <img src="/static/imghwm/default1.png" data-src="/images/online_demo/klematis.jpg" class="lazy" title="flowers" alt="css 属性选择器 - 根据html元素的name属性值选择改元素" > <img src="/static/imghwm/default1.png" data-src="/images/online_demo/klematis.jpg" class="lazy" title="landscape" alt="css 属性选择器 - 根据html元素的name属性值选择改元素" > <p><b>Note:</b> For [<i>attribute</i>~=<i>value</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p> </code>
在线运行
css属性选择器实例二:
选择一个lang属性的起始值="en"的所有元素
<code class="language-html"> <style> [lang|=en] { background:yellow; } </style> <p lang="en">Hello!</p> <p lang="en-us">Hi!</p> <p lang="en-gb">Ello!</p> <p lang="us">Hi!</p> <p lang="no">Hei!</p> <p><b>Note:</b> For [<i>attribute</i>|=<i>value</i>] to work in IE8 and earlier, a DOCTYPE must be declared.</p> </code>
在线运行
相关阅读:
css选择器

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool