CSS (Cascading Style Sheets)
What is CSS?
CSS (Cascading Style Sheets) is a language used to describe the presentation and styling of HTML
elements on a web page. It controls layout, colors, fonts, spacing, and overall look and feel.
Advantages of CSS
1. Separation of Content and Style: Keeps HTML clean and focuses on structure, while CSS
handles design.
2. Improved Website Design: Allows for more precise and flexible control over the look of pages.
3. Reusability: One CSS file can style multiple pages, reducing redundancy.
4. Faster Page Load: CSS files are cached by browsers, improving load times.
5. Consistency: Ensures a uniform look across all web pages.
6. Easy Maintenance: Changes in style can be done by editing a single CSS file.
Types of CSS
1. Inline CSS: Applied directly to an HTML element using the style attribute.
Example: <p style="color: red;">Text</p>
2. Internal (Embedded) CSS: Written inside a <style> tag within the <head> section.
Example:
<style> p { color: blue; } </style>
3. External CSS: CSS saved in a separate .css file and linked using <link> tag.
Example:
<link rel="stylesheet" href="styles.css">