CSS Basics for Beginners
## Introduction
Welcome to "CSS Basics for Beginners." This book will help you understand the fundamental
concepts of CSS (Cascading Style Sheets),
the language used to style web pages. Whether you're a beginner or looking for a refresher, this
guide will provide a solid foundation in CSS.
## Chapter 1: What is CSS?
CSS (Cascading Style Sheets) is used to style HTML elements and control the layout of web pages.
### Key Features of CSS:
- Controls colors, fonts, spacing, and layout.
- Works with HTML to design visually appealing websites.
- Allows responsive design for different screen sizes.
Example of a simple CSS rule:
body {
background-color: lightblue;
font-family: Arial, sans-serif;
}
## Chapter 2: CSS Selectors and Properties
CSS uses selectors to target HTML elements and apply styles.
### Common CSS Selectors:
- p - Targets all <p> elements.
- #id - Targets an element with a specific ID.
- .class - Targets elements with a specific class.
Example:
h1 {
color: blue;
#unique {
font-size: 20px;
.highlight {
background-color: yellow;
## Chapter 3: CSS Box Model
The CSS Box Model is essential for layout design.
### Box Model Components:
- **Margin** - Space outside the element.
- **Border** - The element's boundary.
- **Padding** - Space between content and border.
- **Content** - The actual content of the element.
Example:
div {
margin: 10px;
padding: 20px;
border: 2px solid black;
## Chapter 4: CSS Flexbox and Grid
CSS provides modern layout techniques like Flexbox and Grid.
### Flexbox Example:
.container {
display: flex;
justify-content: center;
align-items: center;
### Grid Example:
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
## Conclusion
You have learned the basics of CSS, including styling elements, the box model, and layout
techniques like Flexbox and Grid.
Keep practicing and exploring CSS to build beautiful web pages.
Happy Coding!