Docsity

CSS Selectors Cheatsheet, Schemes and Mind Maps of Programming Languages

Partial preview of the text

Download CSS Selectors Cheatsheet and more Schemes and Mind Maps Programming Languages in PDF only on Docsity!

by nana jeon

Feb 2019

CSS selectors cheatsheet by nana jeon is licensed

under a Creative Commons Attribution-NonCommercial-NoDerivatives

4.0 International License.

CSS

selectors

cheatsheet

# >. , * + ~ : [ ] ( ) { }

CSS selectors cheatsheet

Type Selector

a {}

Selector name HTML CSS Infographic

Descendant

Selector

a b {}

a

b c

a b a b

#a

b c

a b a b

a

b c

a b a b

Child

Selector

a > b {}

Combine

Descendant & ID

Selectors

#a b {}

Combine Universal

Selector

a * {}

a b c

ID Selector

<..id=โ€œaโ€/> <..id=โ€œbโ€/> <..id=โ€œcโ€/>

#a {} #a^ #b^ #c

Class

Selector

<.. class=โ€œaโ€/> <.. class=โ€œbโ€/> <.. class=โ€œcโ€/>

.a {} .a (^) .b .c

Combine the Class

Selector

b.x {} (^) a.x (^) b.x c.x

Comma Combinator

Selector

a, c {}

a b c d

Universal

Selector

a b c d

b c

a b a b

a

  • ID is not recommended as a selector

1 / 4 ยฉ Designed by nana jeon 2019

b:only-of-type {}

First of Type

Selector

Nth of Type

Selector

a b a b

b:first-of-type {}

a:nth-of-type(2) {}

a:nth-of-type(even) {}

a:nth-of-type(odd) {}

a:nth-of-type(2n+1) {}

a b a b a

b a

a b a b a

b a

a b a b a

b a

a b a b a

b a

Only of Type

Selector

Last of Type

Selector

a

b b c c d

a :last-of-type {}

b:last-of-type {}

.x:last-of-type {}

  • Those items wonโ€™t be selected as no .x is presented

a

b

a

b b

a

a b c

a

b b b

a b b

a

b c b.x c.x b.x c.x

a

b.x c.x b.x c.x b c

2n+

3 / 4 ยฉ Designed by nana jeon 2019

ยฉ Designed by nana jeon 2019

Only Child

Pseudo

Selector

Only Child Pseudo VS Only of Type

b:only-child {}

Only of Type

Selector

b:only-of-type {}

Empty

Selector

Negation

Pseudo-class

Selector

hello

a:empty {}

a:not(.x) {}

a:not(:last-of-type) {}

  • empty indicates no children elements or text.

a a a

b b

a b a.x b.x

a b a a

hello

Attribute

Selector

Attribute Value

Selector

Attribute Starts

with Selector

Attribute Ends

with Selector

Attribute Wildcard

Selector

[for]

a[for]

a[for=โ€œxโ€]

[for^=โ€œxโ€]

a a[x] a[y] a[z]

a a[x] b[y] c[z]

a a[x] a[y] a[z]

[x] [xy] [yz] [zx]

[x] [xy] [yz] [zx]

[x] [xy] [yz] [zx]

[for$=โ€œxโ€]

[for*=โ€œxโ€]

a

b

a

b b

a

a b c

a

b

a

b b

a

a b c

4 / 4

This cheatsheet is desinged for a quick search on CSS selectors. :) There are so many CSS selectors with unfamiliar symbols, >. , * + ~ [ ] etc, so I am often confused with how CSS selectors work. I wish this infographic helps you find proper CSS selectors. Print this lovely cheatsheet out and stick it on the wall. And if you need more details on CSS selectors, check out my blog at medium.com/@nana.

I would love to hear your feedback on how I can make it better. Please leave your comments on my twitter @nanacodesign. Thank you !!! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!!!

Happy

codesign

today!!!