!DOCTYPE html> Introduction to HTML

basics

Basics of CSS

Basics of CSS

What is CSS?

CSS (Cascading Style Sheets) is used to control the presentation of a web page. It allows you to separate the style (visual layout) from the content (HTML structure), making it easier to manage, update, and customize your site.

CSS Syntax

A CSS rule consists of a selector and a declaration block. The selector indicates the HTML element you want to style, and the declaration block contains one or more declarations, each with a property and value.

/* Example of CSS Syntax */ p { color: blue; font-size: 16px; }

Types of CSS

There are three main ways to apply CSS to a web page:

CSS Selectors

Selectors allow you to target specific HTML elements to apply styles. Here are some basic types:

Box Model

The CSS box model describes the layout and spacing of elements. Each element has content, padding, border, and margin.

Example: Styling a Webpage

Here's an example of how CSS styles can transform the appearance of a webpage:

/* Basic styling example */ body { font-family: Arial, sans-serif; background-color: #f4f4f4; } h1 { color: #333; text-align: center; } p { color: #555; line-height: 1.6; }