公式サイト:Selectors Level 3 - W3C#2. Selectors
公式サイト:Selectors Level 4#2. Selectors Overview
公式サイト:CSS Snapshot 2020 - W3C#5.2. Selector Index
公式サイト:CSS Indexes - W3C#7. Selectors
参考:CSS Reference - MDN#selectors
目次
1. ベーシックセレクター
1-1. ユニバーサルセレクター
ユニバーサルセレクターは全ての要素を指定するセレクターである。全称セレクターとも呼ばれる。
* {outline: solid 1px black;}
1-2. タイプセレクター
タイプセレクターは、要素名で指定するセレクターである。
element {style properties}body {property;}
1-3. クラスセレクター
クラスセレクターは、特定のクラス属性を持つ要素を指定するセレクターである。
.classname {property: value;}
1-4. IDセレクター
IDセレクターは、id属性を持った要素を指定するセレクターである。
#idname {property: value;}
1-5. 属性セレクター
属性セレクターは、特定の属性を持つ要素を指定するセレクターである。
a[title] {}[attr][attr=value][attr~=value][attr|=value][attr^=value][attr$=value][attr*=value][attr operator value i]
2. グルーピングセレクター
2-1. セレクターリスト
セレクターリストは、である。
ul, ol {}
3. コンビネーター(結合子)
3-1. 子孫結合子(Descendant combinator)
子孫結合子(Descendant combinator)は、である。
ul ol {}
3-2. 子結合子
子結合子(Child combinator)は、である。
ul > ol {}
3-3. 一般兄弟結合子(General sibling combinator)
セレクターリストは、である。
ul ~ ol {}
3-4. 隣接兄弟結合子(Adjacent sibling combinator)
セレクターリストは、である。
ul + ol {}
4. 疑似クラスと疑似要素
4-1. 疑似クラス(Pseudo-classes)
疑似クラス(Pseudo-classes)は、である。
a:hover {}
4-2. 疑似要素(Pseudo-elements)
疑似要素(Pseudo-elements)は、である。
a::before {}
2. KnotTextでのCSSの分類
2-1. CSSセレクター
2-1-1. ベーシックセレクター
| ユニバーサルセレクタ― | * { } |
|---|---|
| タイプセレクタ― | element { } |
| クラスセレクタ― | .classname { } |
| IDセレクター | #idname { } |
| 属性セレクタ― | selector[attribute] { } |
| セレクターリスト | div, p { } |
|---|
2-1-3. コンビネーター(結合子)
| 子孫結合子 | div a |
|---|---|
| 子結合子 | div > a |
| 一般兄弟結合子 | p ~ a |
| 隣接兄弟結合子 | p + a |
2-1-4. 疑似クラスと疑似要素
| 疑似クラス | div:hover { } |
|---|---|
| 疑似要素 | div::before { } |
2-2. CSSプロパティ
| 3D | perspective, backface-visibilityなど | |
|---|---|---|
| animation | animation, transform, transitionなど | |
| boxmodel | outline, margin, border, padding, background, overflow, z-index, height, width, positionなど | |
| counter | counter-increment, counter-reset, counter-setなど | |
| custom | --* | |
| element | box-shadow, box-sizing, object-fit, object-position, opacity, mix-blend-mode, visibility, content, display, text-overflow, float, clear, empty-cells, caption-side, list-styleなど | |
| graphics | backdrop-filter, filter, shape-image-threashold, shape-margin, scale, image-rendering, aspect-ratio, mask, clip, clip-path, inset, outsetなど | |
| internationalization | line-break, writing-mode, text-orientation, text-combine-upright, direction, unicode-bidi, block-size, inline-sizeなど | |
| layout | column-rule, flex, grid, align-content, align-items, align-self, align-tracks, justify-content, justify-items, justify-self, order, column-count, column-fill, column-gap, columns, column-span, column-width, gap, row-gap, place-content, place-items, place-self, vertical-alignなど | |
| performance | forced-color-adjust, text-rendering, content-visibility, will-change, color-scheme, contain, color-adjustなど | |
| text | word-spacing, text-shadow, text-transform, text-underline-offset, text-underline-position, white-space, shape-outside, text-align, text-align-last, text-indent, text-justify, letter-spacing, line-height, line-height-step, widows, word-break, word-wrap, color, hanging-punctuation, hyphens, initial-letter, orphans, quotes, font, text-decoration, text-emphasis, break-after, break-before, break-insideなど | |
| user-interface | scroll-margin, scroll-padding, overscroll-behavior, user-select, touch-action, caret-color, cursor, resize, pointer-events, scrollbar-color, scrollbar-gutter, scrollbar-width, scroll-behavior, scroll-snap-align, scroll-snap-typeなど | |
| その他のCSSプロパティ | ||
2-3. CSSプロパティの値
| Length | px pt vh... |
|---|---|
| inherit, unset... | |
| !important | |
| Functions | attr(), calc(), clamp(), max(), min()... |
| Angle | deg, grad, rad, turn... |
| Resolution | dpi, dpcm, dppx, x... |
| Time | s, ms... |
| Frequency | Hz, kHz... |
| その他の値 | |
2-4. @ルール
| @font-face | Webフォント |
|---|---|
| @namespace | |
| @media | @media(min-width: 540px) { } |
| @supports | |
| @charset | @charset 'utf-8'; |
| @page | |
| @counter-style | |
| @color-profile | |
| @keyframes | |
| その他の@ルール | |
W3C CSS Validation Service は CSS が正しく書かれているかを判定するために利用できます。デバッグのために重宝するツールです。