tags:

views:

33

answers:

4

I have

<div>
  <center>
    <img>
  </center>
</div>

I've tried div img, div center img, div > img, can't seem to get it right.

+1  A: 

the center tag deprecated use styles instead e.g. margin: 0 auto;

matpol
+2  A: 

img, center img, div img and div center img will all work. If you've tried this and it isn't working, it's not your selector that's failing.

meagar
+1 Just tested, very true.
Majid
+2  A: 

You shouldn't use center tags because it has been deprecated, to display something in the center try:

CSS:

div img {
text-align: center;
/*or margin: 0 auto;*/
}

HTML:

<div>
  <img>
 </div>

Hope it helps. :)

Kyle Sevenoaks
Doesn't answer or even address the question asked, you're simply critiquing his code.
meagar
No, but the `<center>` tag has in fact been deprecated, even if it is still supported, it shouldn't be used.
Kyle Sevenoaks
@Kyle That's what comments are for.
meagar
+1  A: 

I'm not quite clear on what you're trying to do.

If you're trying to get the <img>:

div img

should do it.

If you're trying to get <div>s that contain <center>, CSS doesn't do 'backtracking', so I'm not sure if that can be done.

As others have said, the <center> tag is not the best thing to use if you can avoid it.

cofiem