Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I create featured images, the markup that wordpress produces has inline css. The image tag for the image has width and height parameters.

This is very frustrating: I'd like to control the image style with my own css.

How can I remove the inline style?

share|improve this question
1  
Take a look to How to Answer[1] of mr Jiang [1]: wordpress.stackexchange.com/a/115717/14536 –  Oleg Butuzov Oct 10 '13 at 21:45
    
Inline height and width attributes can be overridden from a stylesheet. –  s_ha_dum Oct 10 '13 at 21:52
    
No they can't. That's not how css works. Inline style overrides stylesheet rules. –  bob Oct 11 '13 at 1:39

2 Answers 2

You set the featured image sizes in your functions file:

add_image_size( 'featured-image', 300, 100, TRUE );

Then you can style the featured image from your style.css file.

Or you can over ride the default using CSS.

.wp-post-image { 
 your declarations
 }

Change the class for your featured image to match your theme.

share|improve this answer

You are correct, Inline CSS will always take priority over any CSS in the stylesheet unless you're peppering your CSS with !important's and/or mile-long selectors - which is bad practice. Try checking out this other question which has the solution, Filter to remove image dimension attributes.

Hope that helps!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.