CSS provides styles to HTML elements on the page. Inline styling involves usage of the style attribute in tags, and is highly discouraged. Internal stylesheets use the tag and are used to declare rules for directed portions of the page. External stylesheets may be used through a tag which takes an external file of CSS and applies the rules to the document. This topic covers usage of all three methods of attachment.
External Stylesheet Use
Use the link attribute in the document’s head:
You can also use stylesheets provided from websites via a content delivery network, or CDN for short. (for example,
Bootstrap):
Generally, you can find CDN support for a framework on its website.
Internal Stylesheet
You can also include CSS elements internally by using the tag:
Multiple internal stylesheets can be included in a program as well.
Inline Style
You can style a specific element by using the style attribute:
This text will appear in red.
Note: Try to avoid this — the point of CSS is to separate content from presentation.
Multiple Stylesheets
It’s possible to load multiple stylesheets:
Note that later files and declarations will override earlier ones. So if general.css contains:
body { background-color: red; }
and specific.css contains:
body { background-color: blue; }
if both are used, the background of the document will be blue.