Start with this code:
<ul> <li style="color: blue;">One</li> <li style="color: blue;">Two</li> <li style="color: blue;">Three</li> <li style="color: blue;">Four</li> </ul>
Let's say that today you decide to change the link color to red. Since these styles are inline, you need to go through each element and change the style attribute. Imagine doing this on 10, maybe 20 pages of HTML, and you will understand why this is becoming a problem.
Using a stylesheet separates the contents:
<ul> <li>One</li> <li>Two</li> <li>Three</li> <li>Four</li> </ul>
From style:
ul li { color: blue; }
If you used a stylesheet from the start, changing the color is as simple as changing blue to red in your stylesheet.
In addition to simplifying the style of the document, there is also a selector specificity. Imagine that you inherited the first piece of code from a previous developer and would like to change the color again, but you (being a good developer) prefer style sheets:
ul li { color: red; }
You will soon be disappointed and resort to using !important , as your selectors cannot override inline styles.
Blender Mar 02 '13 at 3:21 2013-03-02 03:21
source share