CSS stands for Cascading Style Sheets. It’s used to control how HTML elements are displayed — including colors, fonts, spacing, and layout.
CSS helps you separate the content (HTML) from the design (CSS). This makes your website cleaner, more organized, and easier to maintain.
<p style="color: red;">Red Text</p><style>
p { color: green; }
</style><link rel="stylesheet" href="styles.css">CSS uses a selector to target an element and apply one or more style declarations:
selector {
property: value;
}Example:
p {
color: blue;
font-size: 16px;
}p {
color: blue;
}.).highlight {
background-color: yellow;
}#)#main-title {
font-size: 24px;
}* {
margin: 0;
padding: 0;
}h1, h2, p {
font-family: Arial, sans-serif;
}div p {
color: gray;
}div > p {
font-weight: bold;
}input[type="text"] {
border: 1px solid black;
}a:hover {
color: red;
}CSS follows a "cascading" priority model:
Specificity and !important can override the default cascade.
Create a simple HTML page that links to an external CSS file. Style the body with a light background color and change the font to Arial.
<!-- index.html -->
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Welcome!</h1>
<p>This page is styled with CSS.</p>
</body>
</html>/* styles.css */
body {
background-color: #f9f9f9;
font-family: Arial, sans-serif;
}You can copy and paste this code in your IDE to run!
Ask the AI if you need help understanding or want to dive deeper in any topic