4

Possible Duplicate:
What is the difference between a pseudo-class and a pseudo-element in CSS?

What do the following mean in CSS?

  1. Pseudo class
  2. Pseudo selectors
  3. Pseudo element

What is the usefulness of each?

Community
  • 1
  • 1
Inquisitive
  • 6,637
  • 13
  • 46
  • 56
  • 1
    @SLaks: I imagine the reaction from the OP will be "that question doesn't say anything about pseudo-selectors!" – BoltClock Jun 28 '12 at 14:48
  • 6
    @SVS w3schools is one of the worst sites to learn coding . Check http://w3fools.com/ – Inquisitive Jun 28 '12 at 14:49
  • 1
    @Subhra: Then have you checked http://www.w3.org yet? I answered your question because despite what SVS and gar_onn said, you won't find satisfactory results using Google (especially for "pseudo-selectors"), but at the same time I downvoted your question because it's poorly-written and shows no sign of research... unlike your previous question. – BoltClock Jun 28 '12 at 14:59
  • 1
    @BoltClock Thanks for answering first of all . Well I knew that possible there could be a duplicate of the same but then I also saw the term "Pseudo Selectors " and that confused me even more. Anything in http://www.w3.org/ is so much elaborate that I find experts answering the relevant parts more useful. I do not mnd getting some down votes but what matters is that I learnt something from the post. – Inquisitive Jun 28 '12 at 15:11
  • Too harsh on the down-votes... – frnhr Aug 05 '13 at 23:15
  • 2
    I found the question to be useful so +1 – Ahmed Masud Dec 03 '14 at 03:39

1 Answers1

21

Pseudo-classes are used to select elements according to information that you can't otherwise express using attributes, IDs or classes (or any other info available through the DOM). For example, :root, :first-child, :last-child, :lang() and :not().

Pseudo-elements are mock elements that you can apply styles to selectively as part of other actual elements, but aren't themselves members of the DOM. For example, content fragments such as ::first-line and ::first-letter, or generated content such as ::before and ::after.

"Pseudo-selectors" is an umbrella term used to cover both kinds of selectors (or really any selector that begins with at least one :), but it is itself meaningless, because in Selectors, pseudo-classes and pseudo-elements are two fundamentally different things.

BoltClock
  • 630,065
  • 150
  • 1,295
  • 1,284
  • 4
    It's worth noting that pseudo-elements only officially got the double colon (::) syntax starting with CSS3, they still work with a single colon (:) for the sake of backwards compatibility. – Daniel Imms Aug 21 '12 at 04:58
  • 3
    After so many downvotes, I just wanted to say thanks for giving a good answer. I think the question is very valid, and this helped me understand. Thanks! – Danny Bullis Sep 04 '13 at 20:02