Override bits of a CSS class while inline?

Posted by larryq on Stack Overflow See other posts from Stack Overflow or by larryq
Published on 2012-10-05T21:00:38Z Indexed on 2012/10/05 21:37 UTC
Read the original article Hit count: 274

Filed under:
|
|

I have an html img that is being styled by a CSS class. I would like to override the width and height values used in that class under some circumstances.

I'm building this img tag using something called a TagBuilder class, provided by Microsoft for the .Net system, which allows developers to assign attributes to an html element.

In this case a CSS class has been assigned to the img tag, and I can assign width and height attributes individually, but they're not taking precedence over the values set in the CSS class.

My tag looks like this currently:

<img alt="my link" class="static" height="240" id="StaticImage" src="http://imageserver.com/myImage.jpg" width="240">

The static CSS class has width and height values of 300 each, and as you can see I'm trying to override them with 240. It's not working in this instance but can I do it without a second CSS class?

© Stack Overflow or respective owner

Related posts about css

Related posts about class