I wrote a HTML/CSS snippet that is included in some 3-rd party website.
But CSS rules of that website make my snippet look terrible. To keep the snippet’s appearance I must use !important keyword, but it’s horrible, I have to write this keyword for about 1000 times (besides such a code looks not very nice).
I can also use inline CSS instead of external .css file, but it’s not a solution too.
So, how can I protect my css styles in some elegant way?
I wrote a HTML/CSS snippet that is included in some 3-rd party website. But
Share
The suggestion to use a
divwith a unique ID is good. However, there is a chance that other rules in the host page’s style sheet use!important. Those rules would override yours, even if you use a unique ID.Short of using an external document in an
iframein the first place (which is not always possible), using!importantis the only 100% safe way that I can see.