CSS Syntax

CSS Tutorial

CSS Advanced

CSS Responsive

CSS Grid

CSS Syntax

The selector refers to the HTML element that you desire to style.

The declaration block consists of one or more declarations separated by semicolons.

Each declaration includes a CSS property name and a value, separated by a colon.

 To differentiate multiple CSS semicolons are used and declaration blocks are surrounded by curly braces.

Example

<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>
</body>
</html>

Example Explained

  • p is a selector in CSS .
  • color is a property, and red is the value of the property.
  • text-align is a property, and center is the value of the property