Jump to content

Delete one of two contradicting CSS rules?

Recommended Posts

In a webpage I have the following HTML code:

<img class="logo" src=....>...</img>

with the corresponding CSS:

.logo {
    width: 12rem;
img {
    width: auto !important;


As you can see there are two somehow contradicting width values. Ok, since the width in IMG has an !important postfix it has a higher priority.

And this is the problem.

How can I disable the width value/key in IMG CSS specification and let the width value for .logo become active?

How can I delete a CSS key?

Since "auto" is already the default value overwriting it with the default value makes no sense.

I have no access to the original html/CSS code but must apply it afterwards

Thank you



Edited by pstein

Share this post

Link to post
Share on other sites

Its the wrong way round, img selector top that becomes default (without !important), .logo below will make it have precedence over just img selector.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...