CSS which takes precedence, inline or the class?

Viewed 32521

My website has a stylesheet defined in the header as style.css with a selector:

.myClass {background:#000;}

Now my div looks like:

<div class="myClass" style="background:#fff;"> &nbsp; </div>

Which one has priority, the inline or the class?

4 Answers

There is no 3.Internal or 4.External precedence. Whichever stylesheet comes last in the html page which will get the precedence. Eg.

<style></style>
<link> </link> <!-- Precedence -->


<link> </link> 
<style></style> <!-- Precedence -->
Related