CSS stands for Cascading Style Sheets, which is a language that we use to describe the appearance and formatting of a document written in HTML or XML. CSS controls the layout, colors, fonts, and overall visual presentation of web pages.

Key concepts of CSS

1. Selectors

Selectors are patterns used to select the elements you want to style. For example, you can select elements by their tag name, class, or ID.

  • Example: p selects all <p> (paragraph) elements.

2. Properties

Properties are aspects of the elements that you want to change. Each property has a name and a value.

  • Example: color, font-size, margin.

3. Values

Values are the settings you apply to the properties.

  • Example: color: red; sets the text color to red.

4. Ruleset

A ruleset consists of a selector and a declaration block.

  • Example:
This ruleset changes the text color of all paragraphs to blue and sets their font size to 16 pixels.

5. Class

A class is a way to group elements so you can style them the same way. Classes are defined with a . followed by a name.

  • Example: .highlight { color: yellow; } styles all elements with the class "highlight" to have yellow text.

6. ID

We use an ID to identify a single, unique element. IDs are defined with a # followed by a name.

  • Example: #header { background-color: lightblue; } sets the background color of the element with the ID "header" to light blue.

7. Cascade

The "cascading" part of CSS means that the final appearance of an element can be influenced by multiple styles, with a specific order of precedence. Styles are applied in the following order:

  • Browser default styles
  • External and internal stylesheets (in the <head> of the document)
  • Inline styles (inside the HTML elements)
  • Importance (styles marked with !important)

Common uses of CSS

  • Changing text color and size.
  • Setting background colors and images.
  • Adjusting the spacing between elements (margins and padding).
  • Aligning content (center, left, right).
  • Creating layouts with multiple columns or sections.


  • Use comments (/* comment */) to keep your CSS organized and easy to understand.
  • Start with an external stylesheet for larger projects to keep your HTML clean.
  • Use shorthand properties to simplify your CSS (e.g., margin: 10px 20px; instead of setting each margin side separately).

By learning and using CSS, you can make your web pages more attractive and user-friendly.