Introduction to External CSS
What is CSS?
CSS (Cascading Style Sheets) is a style sheet language used for describing
the look and formatting of a document written in HTML or XML.
Why External CSS?
External CSS allows you to separate the style from the content. This makes
your code cleaner, more organized, and easier to maintain.
How to Link External CSS
To link an external CSS file to an HTML document, use the following syntax
within the <head> section of your HTML file:
<link rel="stylesheet" type="text/css" href="[Link]">
Here, "[Link]" is the name of your external CSS file. Adjust the filename
accordingly.
Basic Structure of External
CSS File
An external CSS file typically contains a series of rules. Each rule has a
selector and a declaration block.
/* [Link] */
body {
font-family : Arial, sans-serif;
background-color : #f4f4f4 ;
color : #333 ;
}
h1 {
color : #009688 ;
}
In this example, the body selector sets the font and background color for the
entire document, while the h1 selector changes the color of all level 1
headings.
Advantages of External CSS
1. Modularity: Changes can be made in one central file, affecting the
entire site.
2. Consistency: Ensures a consistent look and feel across all pages.
3. Ease of Maintenance: Simplifies the process of updating styles.
Conclusion
External CSS is a powerful tool that enhances the presentation and
aesthetics of a webpage. Learning how to use it efficiently will contribute to
creating well-designed and visually appealing websites.