I just need a bit of help adding a text align of center to p
tags if they contain an image. I need this to be able to center attached images within wordpress. Thank you for any and all help you may be able to offer!
Leave a Reply
You must be logged in to post a comment.
You can use
has
to narrow down the set of allp
elements to those which containimg
elements, and then usecss
to change the property:Alternatively, you could use the
:has
selector:However, the
.has
method is faster than the selector.With jQuery:
Just because I ran this through JS Perf, I thought I’d post a plain JS version (that, in Chromium 14/Ubuntu 11.04, is the fastest approach to solving the problem):
Along with a JS Fiddle.
References:
css()
.:has()
.Use has: http://api.jquery.com/has/