作 ▸
特定の属性を持っている・持っていない場合にマッチするCSSセレクタ
以下のように、属性セレクタに属性名だけを書けばOK。
img[width] {
/* width 属性を持っている img タグにマッチ */
}
img:not([width]) {
/* width 属性を持っていない img タグにマッチ */
}
JavaScriptの querySelector
系の関数からも同様。
// src が無い script タグ = ページ内に直接書かれている script タグのみを抽出
document.querySelectorAll('script:not([src])');