Approaches To Use Of CSS
There are a number of ways in which CSS can be deployed:
External CSS Files
The best way to use CSS is to store the CSS data in an external file and link to this file using the <link> HTML element. This approach allows the CSS definitions to be used by every page on your Web site.
Internal CSS
You can store CSS within a HTML by including it using the <style> element within the <head> section at the top of your HTML file. However this approach means the style definitions cannot be applied to other files. This approach is not normally recommended.
Inline CSS
You can embed your CSS inline with HTML elements: for example <p style=”font-color: red” > uses CSS to specify that text in the current paragraph is red. However this approach means that the style definitions cannot be applied to other paragraphs. This approach is discouraged.
Ensure That You Validate Your CSS
As with HTML, it is important that you validate your CSS to ensure that it complies with appropriate CSS standards. There are a number of approaches you can take:
- Within your HTML editor: Your HTML editing tool may allow you to create CSS. If it does, it may also have a CSS validator.
- Within a dedicated CSS editor: If you use a dedicated CSS editor, the tool may have a validator.
- Using an external CSS validator: You may wish to use an external CSS validator. This could be a tool installed locally or a Web-based tool such as those available at W3C .
Note that if you use external CSS files, you should also ensure that you check that the link to the file works.
