DEV Community

Cover image for CSS Fundamentals Explained
Devin Ford
Devin Ford

Posted on

CSS Fundamentals Explained

Have you ever visited a website that made your eyes bleed? Chances are, it was missing one crucial ingredient: CSS.

CSS, or Cascading Style Sheets, is the magic sauce that takes your boring HTML page and transforms it into a visually stunning masterpiece... or at least, makes it look less like a 90s Geocities page.

But where do you start with CSS? Fear not, my friend, because I'm here to guide you through the basics.

Selectors: The Key to Unlocking Your Inner Designer

CSS selectors are like the X-Men of the web development world. They have special powers that allow you to target specific HTML elements and apply styles to them.

For example, you can target all <h1> elements on your page and make them blue and fluffy, like this:

h1 {
  color: blue;
  text-shadow: 0 0 10px #ffffff;
}
Enter fullscreen mode Exit fullscreen mode

Or you can make all links on your page turn into cute little puppies, like this:

a {
  background-image: url(puppy.jpg);
  background-size: cover;
}
Enter fullscreen mode Exit fullscreen mode

Properties: The Building Blocks of Style

CSS properties are like the bricks that make up a building. They allow you to control the look and feel of your HTML elements.

For example, you can control the font size, color, and family of your text like this:

p {
  font-size: 16px;
  color: #333;
  font-family: Arial, sans-serif;
}
Enter fullscreen mode Exit fullscreen mode

Or you can control the size and color of your cute little puppy links, like this:

a {
  width: 200px;
  height: 200px;
  background-color: #ffc0cb;
}
Enter fullscreen mode Exit fullscreen mode

Final Thoughts

With CSS, the possibilities are endless. You can make your website look like a fairy tale, a futuristic sci-fi epic, or even a page straight out of a Lisa Frank notebook. So go forth and unleash your inner designer! The world of bland, eye-bleeding websites needs you.

Top comments (0)