CSS (Cascading Style Sheets) is a stylesheet language used to control the presentation of HTML elements. It enables you to add styles like colors, fonts, layouts, and animations to your web pages.
- Overview
- CSS Basics
- Selectors and Properties
- Working with Colors
- Text and Font Styling
- Box Model
- CSS Layouts
- Resources
- Contribution
CSS is used to style and format the visual appearance of HTML documents. It enhances the user experience by making web pages more visually appealing and easier to navigate.
CSS is a stylesheet language that separates content (HTML) from presentation. It allows you to apply styles like colors, fonts, and layouts to HTML elements.
CSS can be added to HTML documents in three ways:
-
Inline CSS:
<p style="color: red;">This is a paragraph.</p>
-
Internal CSS (in
<style>tags):<style> p { color: red; } </style>
-
External CSS (in a separate file):
<link rel="stylesheet" href="styles.css">
CSS is written using rules consisting of selectors and declarations:
selector {
property: value;
}Example:
h1 {
color: blue;
font-size: 24px;
}-
Element Selector: Targets specific HTML elements.
p { color: green; }
-
Class Selector: Targets elements with a specific class.
.example { font-style: italic; }
-
ID Selector: Targets an element with a specific ID.
#unique { text-align: center; }
- Color: Sets text color.
- Background-color: Sets background color.
- Font-size: Controls text size.
- Margin: Controls space outside elements.
- Padding: Controls space inside elements.
-
Named Colors:
color: red;
-
Hexadecimal Colors:
color: #ff0000;
-
RGB Colors:
color: rgb(255, 0, 0);
-
Apply background colors to elements:
body { background-color: #f0f0f0; }
-
Text Alignment:
text-align: center;
-
Text Decoration:
text-decoration: underline;
-
Font Family:
font-family: Arial, sans-serif;
-
Font Weight:
font-weight: bold;
The box model consists of:
- Content: The actual content of the box.
- Padding: Space between the content and the border.
- Border: The edge around the padding.
- Margin: Space outside the border.
Example:
div {
margin: 10px;
padding: 15px;
border: 2px solid black;
}Flexbox is used for responsive layouts:
display: flex;
justify-content: center;
align-items: center;CSS Grid is a powerful layout system:
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;Your contributions can improve this guide:
-
Fork the repository.
-
Create a new branch:
git checkout -b improve-mysql-guide
-
Make your updates.
-
Commit your changes:
git commit -am 'Enhanced MySQL tutorial' -
Push to the branch:
git push origin improve-mysql-guide
-
Create a Pull Request targeting the Notes directory.
- 12/10/2024
-
This guide is provided as-is without warranties. Use it responsibly and ensure you comply with legal and ethical guidelines.
-
This project is licensed under the MIT License. See the LICENSE file for details.
