Last Updated : 24 Jul, 2025
CSS stands for Cascading Style Sheets. It is a stylesheet language used to style and enhance website presentation. CSS is one of the three main components of a webpage, along with HTML and JavaScript.
CSS was released (in 1996), 3 years after HTML (in 1993). The main idea behind its use is that it allows the separation of content (HTML) from presentation (CSS). This makes websites easier to maintain and more flexible.
How to Add CSS to HTML?There are three different ways to add CSS styles to an HTML document:
1. Inline CSSUse the style attribute on the HTML element to add styles to the web page. It is used for small projects.
HTML
<!-- File name: index.html -->
<html>
<body>
<!-- Using Inline CSS -->
<h3 style="text-align: center;">
Welcome To GFG
</h3>
<p>CSS Tutorial - GeeksforGeeks</p>
</body>
</html>
2. Internal CSS
Place the CSS styles within a <style> tag inside the HTML file, usually inside the <head> section.
HTML
<!-- File name: index.html -->
<html>
<head>
<!-- Using Internal CSS -->
<style>
h3 {
color: green;
}
</style>
</head>
<body>
<!-- CSS is applied here -->
<h3>Welcome To GFG</h3>
<p>CSS Tutorial - GeeksforGeeks</p>
</body>
</html>
3. External CSS
Create a separate CSS file with a .css extension and link this file to your HTML file using the <link> tag in header section. It consider the best practice to add CSS into HTML File.
HTML
<!-- File name: index.html -->
<html>
<head>
<!-- Importing External CSS -->
<link rel="stylesheet" href="style.css" />
</head>
<body>
<p>CSS Tutorial - GeeksforGeeks</p>
</body>
</html>
CSS
/* Write CSS Here *//* External CSS */
/* File name: style.css */
p {
text-align: center;
}
Adding Animations in CSS
CSS allows you to animate HTML elements using the @keyframes rule. Let’s see how you can create a simple animation for a <p> tag. Let's understand this with the help of example:
XML
<html>
<head>
<style>
/* Applying the animation to the <p> tag */
p {
animation-duration: 3s; /* Time for one cycle */
animation-name: slide-in; /* Name of the animation */
animation-iteration-count: infinite; /* Animation repeats indefinitely */
animation-direction: alternate; /* Alternate the direction of the animation */
}
/* Keyframes for slide-in effect */
@keyframes slide-in {
0% {
transform: translateX(-100%); /* Start from the left */
}
100% {
transform: translateX(100%); /* Move to the right */
}
}
</style>
</head>
<body>
<h3 style="text-align: center;">Welcome To GFG</h3>
<p>CSS Tutorial - GeeksforGeeks</p>
</body>
</html>
In this example
This section covers the fundamental topics of CSS, providing a solid base to get you started:
This section covers important CSS properties that control how elements look and work on a webpage. Start with CSS Display to learn how elements are shown and arranged
This section covers all the key techniques you need to style different parts of an HTML page using CSS:
Now you have a basic understanding of CSS. So start with some beginner level projects to clear your concept and to implement in real world applications.
This section focuses on CSS techniques that help you create flexible and adaptable web designs. You’ll learn how to build layouts that work well on different screen sizes and devices, control element spacing, and manage positioning effectively
This Section Covers all the mathematical logic that can be applied in CSS.
This section covers all the interesting facts and features that make CSS a powerful and versatile tool for web design.
Advanced CSS TopicsThis Section contains various information about advanced topics in CSS
Don't miss our CSS Interview Questions and Answers before going for your interview.
CSS FrameworksBonus Resource: CSS Cheat-Sheet for Beginners (2025) - A Basic Guide to CSS.
CSS Frameworks are a collection of pre-written CSS files (and sometimes JavaScript components) that offer reusable code for common tasks such as buttons, grids, forms, and navigation menus.
These CSS frameworks provide a set of standardized, reusable components and a predefined structure, allowing developers to create responsive and aesthetically pleasing websites with reduced effort.
Other Useful CSS ResourcesCSS Versions
This section contains information about the preprocessors used in CSS.
Why learn CSS?CSS is essential for modern web development. Here's why you should learn it:
1. Enhance Visual AppealCSS allows you to style your web pages, making them visually appealing and engaging. Here’s why it matters:
In today’s mobile-first world, responsive design is crucial. CSS empowers you to:
CSS indirectly impacts your site’s SEO. Here’s how:
CSS promotes clean code and separation of concerns:
Learning CSS opens doors to various roles:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4