CSS
External, Internal or Inline? Which Method is Best?
In this article we will discuss three types of CSS. There are others, but we will stick to the 'Basics' right now. [pun intended] Often we are asked which method is best. All of them are useful when utilized for their intended purpose.
External Style Sheet:
An external style sheet is ideal when the style will be applied to many pages. With an external style sheet, you can quickly change the look of your entire web site by changing one file. Each page within your web site must link to the style sheet using the <link> tag. The <link> tag is inserted between the tags. We design all of our web site templates with external CSS as it is the most effective and maintenance free for the end user.
<head> <link rel="stylesheet" type="text/css" href="style.css"> </head>
Internal Style Sheet:
An internal style sheet should be used when a single web page has a unique style from the rest of your site. Often times web template designers make the mistake of using an internal style sheet instead of an external. This is a big boo-boo because the customer will be creating many pages from the template and thus could have hundreds of potential places to change a color (for example). With that in mind, the effectiveness and concept of using CSS is lessened. It would not be quite as bad if they used redundant HTML tags instead of internal CSS, but it certainly would put a damper on one of the main reasons for using cascading style sheets. Internal styles are also inserted between the head tags using the <style> tag as shown below.
<head> <style type="text/css"> body {color: black; background-color: white;} p {color: black;} </style> </head>
Inline Styles:
An inline style should be used when a unique style is to be applied to a single occurrence of an element. Assign the style attribute to the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the font color and background color of a table cell:
<td style="color: white; background-color: black"> Your text would be in this area. </td>
|