CSS Tutorial
Last Updated :
01 Jul, 2024
CSS, or Cascading Style Sheets, is the language used to style and enhance HTML documents. It defines the presentation of HTML elements on a web page, enabling changes to fonts, colors, sizes, spacing, column layouts, and animations.
In this CSS tutorial, we will cover both basic and advanced concepts, including CSS properties, selectors, functions, media queries, and more.

What is CSS?
CSS, or Cascading Style Sheets, is a language used to style and enhance websites. It controls how HTML elements—such as text, images, and buttons—are displayed on a webpage. With CSS, you can adjust font sizes and colors, add backgrounds, and manage the layout, transforming a basic webpage into a visually appealing and user-friendly experience. CSS also simplifies layout management across multiple web pages by using external stylesheets stored in CSS files.
Different Ways to Use CSS
CSS has three ways to style the HTML:
- Inline: Add styles directly to HTML elements using the style attribute (limited use).
- Internal: Place styles within a <style> tag inside the HTML file, usually within the <head> section
- External: Create a separate CSS file with a .css extension and link it to your HTML file using the <link> tag.
Basic CSS Example
In this example, we will use all of them with different properties.
HTML
<!-- File name: index.html -->
<!DOCTYPE html>
<html>
<head>
<!-- Importing External CSS -->
<link rel="stylesheet" href="style.css" />
<!-- Using Internal CSS -->
<style>
h2 {
color: green;
}
</style>
</head>
<body>
<!-- Using Inline CSS -->
<h2 style="text-align: center;">Welcome To GFG</h2>
<p>CSS Tutorial - GeeksforGeeks</p>
</body>
</html>
CSS
/* External CSS */
/* File name: style.css */
p {
text-align: center;
}
Output:

CSS Example Output
Also Check: Recent Articles on CSS
CSS Tutorial
Introduction to Modern CSS
CSS Fundamentals
Understanding CSS basics is necessary whether you’re an experienced developer or just starting your web journey. Let’s explore some key CSS concepts.
CSS Styling Techniques
CSS describes how HTML elements should be presented on the web page. It provides colors, positions to the HTML elements, etc., create animations, and amplify your web page.