-3

My aim is to have this class apply only when set on <img> tags. It only works when there is no space between the tag name and the class name, but doesn't when there is. I have seen style sheets with spaces in the signature, so I'm sure it must be valid in some contexts.

What is the difference between:

img.approved-photo {
    // no space
}

and

img .approved-photo {
    // has a space
}
rhughes
  • 9,257
  • 11
  • 59
  • 87
  • It's to select a child from the element before. ie: An element with class `.approved-photo` within an `img`. – emerson.marini May 30 '14 at 08:18
  • To apply to the element itself, you need to remove the space. – emerson.marini May 30 '14 at 08:18
  • 2
    https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_selectors – deceze May 30 '14 at 08:19
  • *"Does not show any research effort."* - I.e. the question has been asked before, there's ample documentation available and any CSS tutorial teaches this. This question didn't need to be asked. – deceze May 30 '14 at 08:23

1 Answers1

4

The first one applies to an image with class "approved-photo", the second one to an element with class "approved-photo" which has an img element as ancestor.

wonce
  • 1,893
  • 12
  • 18