What is CSS?
CSS stands for Cascading Style Sheets. It is a stylesheet language used to describe the presentation and layout of a document written in HTML or XML. CSS controls how elements appear on the page — including colors, fonts, spacing, and positioning.
Why Use CSS?
CSS separates content from design, making it easier to manage and update the look of your website. It improves the user experience and allows consistent styling across multiple pages.
- Enhances page aesthetics
- Improves code maintainability
- Reduces repetition using external stylesheets
- Supports responsive and adaptive design
Types of CSS
- Inline CSS: Applied directly to an element using the
style
attribute. - Internal CSS: Written inside a
<style>
tag within the HTML<head>
. - External CSS: Stored in a separate
.css
file and linked using the<link>
tag.
Basic Example
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
href="styles.css">
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
And the external CSS file styles.css
:
h1 {
color: blue;
text-align: center;
}
Conclusion
CSS is a powerful tool for designing beautiful and responsive web pages. Learning CSS allows developers to create visually engaging and user-friendly websites.