Premium CSS Course

CSS Basics

CSS (Cascading Style Sheets) is essential for creating visually appealing web pages. In this section, we'll dive into the basics of CSS, including its properties, values, and syntax.

What are CSS Properties?

CSS properties are used to define the styles for HTML elements. They control various visual aspects like color, size, positioning, and more. A property is always followed by a value. For example:


        p {
            color: blue;
        }
    

In the example above, the color property is applied to the <p> element, setting its text color to blue.

CSS Syntax

CSS follows a simple structure: selector + property: value. Here's the breakdown:

CSS Values

Values define how a property is applied. For example:

Common CSS Properties

Best Practices for CSS Basics

Example of CSS Basics

Below is an example that demonstrates how to style a <div> element using the basics of CSS:


        div {
            width: 300px;
            height: 200px;
            background-color: #4CAF50;
            color: white;
            text-align: center;
            padding: 20px;
            border-radius: 8px;
        }
    

This rule will create a <div> with a green background, white text, and centered content with padding.