Skip to content Skip to sidebar Skip to footer

How To Override The Width Property?

How can I override a css width so that a competing width HTML attribute defines the computed size? The following example is rendered with a width of 500px, but I want 100px. Assume

Solution 1:

You can use inline style to set width

img {
  width: auto;
}
<imgsrc="http://placehold.it/500x500"style="width: 100px">

Solution 2:

Take a look at the !important tag:

More info here

Solution 3:

You can use inline css:

<imgsrc="http://placekitten.com/500/500"style="width:100px">

or you can just remove the px from your current code:

<imgsrc="http://placekitten.com/500/500"width="100">

Solution 4:

you can use !important annotation : width: 100px!important;

Solution 5:

Simply use like this

img {
width: auto;}

<img src="http://placekitten.com/500/500" style="width: 100px;">

Post a Comment for "How To Override The Width Property?"