I'm seeing a strange behaviour which i'm not able to figure out.
The webpage that i'm working on has a lot of css styles. So for one of my div's i'm using inline css to make the width as per my requirement (which shows up in the source code just fine). But when i'm inspecting the element in Google Chrome i see that the computed width as slightly less than my value. How do i override the computed value.
Thanks
The only way to override inline style is by using ! important keyword beside the CSS rule.
The max-width property in CSS is used to set the maximum width of a specified element. The max-width property overrides the width property, but min-width will always override max-width whether followed before or after width in your declaration.
Inline styles added to an element (e.g., style="font-weight: bold;" ) always overwrite any normal styles in author stylesheets, and therefore, can be thought of as having the highest specificity.
The height and width of an inline element cannot be set in CSS. You cannot set the height and width of block-level elements in CSS. Inline elements flow left to right, meaning inline elements appear on the same line unless the line wraps or there's an explicit line break ( <br/> )
Try with !important to override any value.
#div {width:500px !important;}
Could you please provide more sample code. This is not enough information to answer the question properly. As stated by miduga, !important
should be enough to override that style.
Are you certain that this element is of the correct display type? Remember that you can't define a width for inline elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With