CSS Tutorial
CSS Tutorial
CSS Tutorial
This CSS tutorial covers everything from basic styling concepts and selectors to
advanced techniques, such as flexbox, grid, animations, and CSS variables. This CSS
tutorial is designed to help both beginners and experienced designers to make them
masters in creating visually appealing, responsive, and modern web designs.
What is CSS
CSS is the acronym for "Cascading Style Sheet". It's a style sheet language used for
describing the presentation of a document written in a markup language like HTML. CSS
helps the web developers to control the layout and other visual aspects of the web
pages. CSS plays a crucial role in modern web development by providing the tools
necessary to create visually appealing, accessible, and responsive websites.
CSS Versions
Since the inception of CSS, several versions have came into existence. Some of the
notable versions include:
CSS1 (Cascading Style Sheets Level1) - The initial version of CSS, released in
December 1996. CSS1 provided basic styling capabilities for HTML documents,
including properties for text, colors, backgrounds, margins, and borders.
https://www.tutorialspoint.com/css/index.htm 1/10
Page 2 of 10
Each version of CSS builds upon the previous ones, adding new features and refining
existing capabilities to meet the evolving needs of web developers and designers. CSS is
referred as just CSS now, without a version number.
Types of CSS
Inline CSS: Inline CSS is applied directly to an HTML element using the style attribute.
It has the highest priority among the three methods.
Example
Open Compiler
Internal CSS: Internal CSS is defined within the <style> tag inside the <head> section
of an HTML document.
Example
Open Compiler
<head>
<style>
p { color: green; font-size: 18px; }
</style>
</head>
<body>
<p>This line is styled using internal CSS.</p>
</body>
External CSS: External CSS is written in a separate .css file and linked to the HTML
document using the <link> tag. This is the recommended method for large projects as it
improves maintainability.
Example
https://www.tutorialspoint.com/css/index.htm 2/10
Page 3 of 10
/* styles.css */
p { color: red; font-size: 20px; }
Responsive design - CSS offers features like media queries that enable
developers to create responsive layouts that adapt to different screen sizes and
devices, ensuring a consistent user experience.
Flexibility and Control - CSS provides precise control over the presentation of
HTML elements, allowing developers to customize layout, typography, colors, and
other visual properties.
Consistency and Reusability - Developers can ensure consistency across the
entire website, by defining styles in a central CSS file. Styles can be reused
across multiple pages, reducing redundancy and making updates easier.
Components of CSS
CSS works by associating rules with HTML elements. A CSS rule contains two main parts:
Each declaration includes a property name and a value, specifying the aspect of the
element's presentation to control.
CSS Example
Just to give you a little excitement about CSS, here is a sample CSS snippet for your
reference.
https://www.tutorialspoint.com/css/index.htm 3/10
Page 4 of 10
Open Compiler
<html>
<head>
<title>CSS Tutorial</title>
<style>
h1 {
color: #36CFFF;
}
p {
font-size: 1.5em;
color: white;
}
div {
border: 5px inset gold;
background-color: black;
width: 300px;
text-align: center;
}
</style>
</head>
<body>
<div>
<h1>Hello World!</h1>
<p>This is a sample CSS code.</p>
</div>
</body>
</html>
h1, p, and div are the selectors that target the <h1>, <p>, and <div>
elements.
color, font-size, border, background-color, width, and text-align are the
properties.
#36CFFF, 1.5em, white, 5px inset gold, black, 300px, and center are the
corresponding values passed to these properties.
For a quick glance of CSS properties and features, check our CSS Reference page.
https://www.tutorialspoint.com/css/index.htm 4/10
Page 5 of 10
CSS Basics
Understanding the basics is important whenever you are learning something new. So
before diving deep into CSS please know fundamentals of CSS.
CSS Introduction
CSS Syntax
CSS Selectors
CSS Inclusion
CSS Comments
CSS Properties
CSS properties and selectors are the main thing in CSS, without the properties there is
no ways to define the styling of any HTML element. So better to know most frequently
used properties in one go will help you to work with CSS.
CSS Background
CSS Border
CSS Display
CSS Float
CSS Font
CSS Opacity
CSS Overflow
CSS Padding
CSS Position
CSS Align
CSS Width
CSS Height
https://www.tutorialspoint.com/css/index.htm 5/10
Page 6 of 10
CSS Outline
CSS Visibility
CSS Counter
You can get complete list of CSS Properties on the attached link.
CSS Advanced
After completing the above two section you can proceed with the advance part of this
tutorial, these topics will helps you to make an actual website layout.
CSS Animation
CSS Gradient
CSS Transition
CSS Tooltips
CSS Arrow
CSS Grid
CSS FlexBox
CSS 2D Transforms
CSS 3D Transforms
CSS Practice
The following are some of the important links to practice CSS:
CSS Cheatsheet
https://www.tutorialspoint.com/css/index.htm 6/10
Page 7 of 10
If you are new to HTML and XHTML, then we would suggest you to go through our HTML
or XHTML Tutorial first.
CSS are used to style or decorate the web pages, it will help you to create a beautiful
website. CSS specify how an HTML element should be displayed on the web page. If you
think of the human body as a web page then CSS is styling part of the body.
Yes, there are CSS frameworks which can be used as an alternative of CSS. But you can
not replace the main CSS without having knowledge of basic CSS.
https://www.tutorialspoint.com/css/index.htm 7/10
Page 8 of 10
The current version of CSS is 3.0 but CSS 4.0 is an ongoing effort to extend CSS3 with
new features and enhancements.
Yes, CSS can't provide maximum security, or you can say the purpose is not to provide
that kind of security for your website. Lots of browsers required different properties for
the same functionality(cross-browser issue).
TOP TUTORIALS
Python Tutorial
Java Tutorial
C++ Tutorial
C Programming Tutorial
C# Tutorial
PHP Tutorial
R Tutorial
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
SQL Tutorial
TRENDING TECHNOLOGIES
Git Tutorial
Ethical Hacking Tutorial
Docker Tutorial
Kubernetes Tutorial
DSA Tutorial
Spring Boot Tutorial
SDLC Tutorial
https://www.tutorialspoint.com/css/index.htm 8/10