John Sean John Sean - 27 days ago 7
CSS Question

Can someone describe this CSS selectors please?

Please give me a explanation on what this selectors do please:


  1. img[alt$="a"]

  2. li:odd p

  3. p:nth-child(2n +1)

  4. input:not([required])

  5. ul li.selected p::before


KBJ KBJ
Answer

You should try googling a bit before you resolve to asking this kind of questions.

img[alt$="a"]

Selects every <img> element with alt attribute value ending with a

li:odd p

Selects every paragraph <p> under every odd <li>

p:nth-child(2n +1)

Selects every (2n+1)th paragraph

input:not([required])

Selects every <input> element that's not required

ul li.selected p::before

Inserts something before the content of each <p> element under every <li> element with selected class

Comments