
Introduction in CSS
? CSS Introduction
CSS (Cascading Style Sheets) is the language used to describe the presentation and layout of web pages. It controls how HTML elements look on the screen, paper, or other media.
What is CSS?
CSS stands for Cascading Style Sheets.
It defines styles such as colors, fonts, spacing, positioning, and more.
Works alongside HTML (structure) and JavaScript (behavior).
Enables separation of content (HTML) from design (CSS).
Why Use CSS?
Makes websites visually appealing.
Provides control over layout and design.
Enables responsive design for different screen sizes.
Improves site maintainability by separating style from markup.
Allows reuse of styles across multiple pages.
How CSS Works
Write CSS rules that select HTML elements.
Apply style declarations (properties and values).
Styles cascade and combine according to specificity and importance.
Basic CSS Syntax
selector { property: value; property2: value2;}
Example:
p { color: blue; font-size: 16px;}
Ways to Apply CSS
Inline CSS: directly inside an HTML element.
<p style="color: red;">Hello</p>
Internal CSS: inside a
<style>
block in the HTML<head>
.
<style> p { color: green; }</style>
External CSS: in a separate
.css
file linked with<link>
tag.
<link rel="stylesheet" href="styles.css">
CSS Terminology
Selector: targets HTML elements.
Property: aspect of style to change (color, margin, etc.).
Value: setting for the property.
Rule/Rule set: selector + declaration block.
Declaration: a single property-value pair.
Summary
CSS is essential for designing modern websites, giving control over colors, fonts, layouts, and effects, making web pages visually engaging and user-friendly.
Want me to help you start writing your first CSS styles or explain core concepts like selectors, box model, or layout?