CSS (Cascading Style Sheets) is a stylesheet language used to describe the presentation of an HTML document. It controls the layout, colors, fonts, spacing, and responsiveness of web pages.
p {
color: blue; /* Text color */
font-size: 16px; /* Font size */
}
<p style="color: red;">This is red text.</p>
<style>
p {
color: green;
}
</style>
<link rel="stylesheet" href="styles.css">
Selector | Description | Example |
---|---|---|
Element | Targets all elements of a type | p { color: blue; } |
Class (`.`) | Targets elements with a specific class | .button { background: red; } |
ID (`#`) | Targets a unique element | #header { font-size: 24px; } |
div {
width: 200px;
padding: 10px;
border: 2px solid black;
margin: 20px;
}
.fixed-box {
position: fixed;
top: 10px;
right: 10px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
}
.grid-container {
display: grid;
grid-template-columns: 1fr 2fr;
}
@media (max-width: 600px) {
body {
background-color: lightgray;
}
}
CSS is a powerful language that styles and formats web pages, making them visually appealing and responsive. Mastering CSS allows for professional, well-structured web designs.
Would you like examples for a specific CSS feature? 🚀