spacer
Yehuda Shiran September 1, 2000
Resolving Conflicting Styles
Tips: September 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

You can define an element's style in many different ways. There is a pre-defined priority order between these methods. An element's own scripting always has the highest priority. Its own inline STYLE is next, and own inline CLASS is after that. Inherited scripting, STYLE, and CLASS are in lower priority, in this order. The following examples demonstrate this concept:

Notice the style assignment hierarchy: setting color by inherited CLASS

Here is the HTML code for the example above:

<DIV CLASS="textBlue">
  <SPAN>
    Notice the style assignment hierarchy: setting color by inherited CLASS 
  </SPAN>
</DIV>

Notice the style assignment hierarchy: setting color by inherited inline STYLE

Here is the HTML code for the example above:

<DIV CLASS="textBlue" STYLE="color: red">
  <SPAN>
    Notice the style assignment hierarchy: setting color by inherited inline STYLE 
  </SPAN>
</DIV>

Notice the style assignment hierarchy: setting color by inherited scripting

Here is the HTML code for the example above:

<DIV CLASS="textBlue" STYLE="color: red" onMouseOver="this.style.color = 'tan'" 
  onMouseOut="this.style.color = 'purple'">
  <SPAN>
    Notice the style assignment hierarchy: setting color by inherited scripting
  </SPAN>
</DIV>

Notice the style assignment hierarchy: setting color by own CLASS

Here is the HTML code for the example above:

<DIV CLASS="textBlue" STYLE="color: red" onMouseOver="this.style.color = 'tan'" 
  onMouseOut="this.style.color = 'purple'">
  <SPAN CLASS="textYellow">Notice the style assignment hierarchy: 
    setting color by own CLASS 
  </SPAN>
</DIV>

Notice the style assignment hierarchy: setting color by own inline STYLE

Here is the HTML code for the example above:

<DIV CLASS="textBlue" STYLE="color: red" onMouseOver="this.style.color = 'tan'" 
  onMouseOut="this.style.color = 'purple'">
  <SPAN CLASS="textOrange" STYLE="color: magenta">
    Notice the style assignment hierarchy: setting color by own inline STYLE 
  </SPAN>
</DIV>

Notice the style assignment hierarchy: setting color by own scripting

Here is the HTML code for the example above:

<DIV CLASS="textBlue" STYLE="color: red" onMouseOver="this.style.color = 'tan'" 
  onMouseOut="this.style.color = 'purple'">
  <SPAN CLASS="textOrange" STYLE="color: magenta" 
    onMouseOver="this.style.color = 'green'" 
    onMouseOut="this.style.color = 'brown'">
    Notice the style assignment hierarchy: setting color by own scripting 
  </SPAN>
</DIV>

Learn more about the subject in Column 66, Dynamic Styles.


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger