Wednesday, February 4, 2015

Override Inline CSS Styles - HTML / CSS trick

Sometimes there is a need to override inline style with css. Good example might be the code where you don’t have an option to remove a markup , where finding a place where inline code is coming from might be a challenge.

Here is how you can override it. There are two elements involved in doing that:

  [style]   addition to existing css code
  !important  line in css code

<div class="FirstDiv" style="background: red;"> The inline styles for this div should make it red. </div>

You can overwrite/change the above in-line css by the below method

<style="text/css">

div[style].FirstDiv
{
background: green !important;
}

</style>












1 comment:

  1. Extremely useful information which you have shared here about CSS selectors. This is a great way to enhance knowledge for us, and also beneficial for us. Thank you for sharing a post like this. Web Design & Development Company in Pune

    ReplyDelete