Style declarations and class css. I need advice!

Hi all,

I am in a situation in which I HAVE to define an image align and some other style elements within the Image tag. However, these are just for the editor (FCKeditor 2.6x) The image also has a class declaration (class="WB_ImgLeft") which is defined in a css on the actual web page. I would much rather that the editor too would use this css however, it cannot.

What are the rules for having both style definitions within the tag and a class. Does one over-rule the other. If I have padding in the style definition in the tag and padding defined in the css do they get combined to an aggregate value or does the css take charge?

Example of code:
<img class="WB_ImgLeft" title="Family day out" border="2" alt="Family day out" align="left" style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; margin-right: 5px; padding-top: 5px" src="" />

Kind regards.

Abiel M de groot

Abiel de GrootDeveloperAsked:
Who is Participating?
Generally speaking, the closer to the content a style is declared, the more priority that style has. Thus a style item within the <img> tag will override a style written in the <head> section which will override an external stylesheet.  There are exceptions, for example adding the tag !important grants a style higher order of precedence.  The full set of rules is discussed here:

The important thing for your current situation is that the style code in the <img> tag is likely to have the highest precedence and it will override styles previously defined with which it conflicts.
Juan OcasioApplication DeveloperCommented:
I guess the curiousity is getting the best of me.  Why do you HAVE to have styles in the markup?  Is it just so you can see the page properly in the editor?  My advise would be to delete the styles in the markup once you have gotten everything correct and then transfer it into the class definition in the CSS.  But to your questions if you have padding-right in the markup and padding-left in the css, they would be combined.  If you had padding-right in the markup and css, the markup will take presidence as it is rendered after the css file is read.
Abiel de GrootDeveloperAuthor Commented:

I understand your curiosity. can I refer you to my following question. Still waiting for an answer.


many thanks all. i will leave this open a bit longer.
Abiel de GrootDeveloperAuthor Commented:
Many thanks guys
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.