Introduction to CSS
CSS (Cascading Style Sheets) is a stylesheet language used to control the appearance and layout of web pages. It allows developers to style HTML elements by defining properties such as colors, fonts, spacing, and positioning.
With CSS, you can:
✔ Change text and background colors
✔ Adjust font styles and sizes
✔ Control element positioning (Flexbox, Grid)
✔ Create animations and transitions
✔ Make web pages responsive for different screen sizes
CSS enhances user experience by making websites more visually appealing, structured, and accessible across devices.
1. CSS Kya Hai?
CSS stands for Cascading Style Sheets. It is a stylesheet language used to define the layout, colors, fonts, spacing, animations, and responsive design of HTML elements.
1.1 Why is CSS Important?
HTML and CSS are separate: HTML defines the structure, while CSS manages the design and presentation.
Efficient and reusable code: A single CSS file can be used to style multiple pages.
Responsive design: CSS helps make websites mobile-friendly.
HTML and CSS are separate: HTML defines the structure, while CSS manages the design and presentation.
Efficient and reusable code: A single CSS file can be used to style multiple pages.
Responsive design: CSS helps make websites mobile-friendly.
2. How to Use CSS?
CSS can be applied in three ways:
2.1 Inline CSS
Inline CSS applies styles directly within an HTML tag.
2.2 Internal CSS
Internal CSS is written inside the <style>
tag in the <head>
section of an HTML document.
2.3 External CSS
External CSS is written in a separate file and linked to an HTML file.
styles.css
file:
HTML file:
3. CSS Selectors
CSS selectors are used to target specific HTML elements.
3.1 Types of Selectors
Element Selector
Class Selector
ID Selector
Group Selector
Universal Selector
4. CSS Properties
4.1 Colors
4.2 Backgrounds
4.3 Borders
4.4 Font Styling
4.5 Box Model
5. CSS Flexbox
Flexbox is a powerful layout system that helps in aligning and distributing elements easily.
6. CSS Grid
CSS Grid is an advanced layout system for designing complex page structures.
7. CSS Animations
8. Responsive Design with Media Queries