πŸ’‘ This page contain affiliate links. By making a purchase through them, we may earn a commission at no extra cost to you.

CSS

CSS (Cascading Style Sheets) is a stylesheet language used to describe the presentation of a document written in HTML. It is a core part of the web that lets you create stunning designs, interactive elements, and animations.

What you see below is CSS Zen Garden, a popular site that demonstrates the variety and flexibility of CSS, and how the same document can be represented in vastly different ways. All three pages have the same content, except they use different CSS.

CSS can alter the look and feel of the same layout
CSS Zen Garden demonstrates how CSS can alter the look and feel of the same document

Why Should I Learn CSS?

Still, the question remains: why should I care about learning CSS? What's in it for me? Here are four reasons to help you decide whether you should invest your time in learning CSS:


Show Me How CSS Works

Let's take a look at a simple example to see how CSS works. In the following code, we have a .loader class styled as a loading indicator using CSS borders and animations.

Copied to clipboard! Playground
.loader {
    width: 50px;
    height: 50px;
    border: 10px dotted #FCBA28;
    border-radius: 100%;
    animation: loading 1s linear infinite;
}

@keyframes loading {
    0%   { transform: rotate(0deg);  }
    100% { transform: rotate(360deg); }
}
loader.css
Example of a spinning loader in CSS

To style elements in CSS, we need to reference them using a query selector, such as their class. In this example, we reference a div with a class of .loader. Inside curly braces, we can style the element with CSS properties, consisting of name and value pairs:

To better understand how these CSS rules work together, use the interactive example below. Changing the controls will affect the visuals of the loader.

{
    "width": "50px",
    "height": "50px",
    "border-radius": "100%",
    "border-width": "10px",
    "animation-duration": "1s",
    "border-style": "dotted"
}

Where Should I Start?

If you are new to CSS, you should start with the basics. First, you need to familiarize yourself with the syntax and the different units that CSS has to offer.

Everything You Need to Know About CSS Units

You will need to know how CSS specificity works and how to construct different selectors that can be used to style elements. A fun game to practice CSS selectors is using the CSS Diner game. You will also need to be aware of how the box model works.

Representation of the box model 
Representation of the box model 

The box model tells the browser the position and size of each element on the page. Each element can be surrounded by paddings (which will be part of the element), as well as a border. Elements can be spaced from each other using margins (which will not be shown visually).

Once you are familiar with the basics and you are comfortable with styling elements, you can start exploring more advanced concepts, such as responsive design and working with complex animations.

If you would like to learn more about CSS, you can find all of our latest tutorials below. Use the filters in the sidebar if you want to narrow down the results. Additionally, you can filter for CSS-related tutorials on our search page. I wish you good luck with learning CSS!

Keep on coding! πŸ‘¨β€πŸ’»

Did you find this page helpful?
πŸ“š More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Access 100+ interactive lessons
  • check Unlimited access to hundreds of tutorials
  • check Prepare for technical interviews
Become a Pro

Courses

Recommended

This site uses cookies We use cookies to understand visitors and create a better experience for you. By clicking on "Accept", you accept its use. To find out more, please see our privacy policy.