CSS Syntax

CSS syntax includes a selector, a property, and its value. The selector points to an HTML element where the CSS style is applied. The CSS property and value are connected by semicolons. This involves matching the selector name with its associated property-value definition.

Syntax:

selector { Property: value; }

CSS_Property

Let’s clarify each of these terms:

  • Declaration: This is made up of a property and the value it should have.
  • Selector: It pinpoints which HTML elements to style.
  • Property: It determines the exact feature of an element you’re changing.
  • Value: It’s the assigned setting for a property, deciding how the element should look or act.

Also read, Why should you Study JavaScript?

Example:

In this example, we’ll take it step by step, using clear and easy explanations.

<!DOCTYPE html>
<html>
<head>
<!-- Style on h1 elements -->
<style>
h1 {
color: red;
text-align: center;
}
</style>
</head>


<body>
<h1>Easy Coding School</h1>
</body>
</html>

Explanation:

  •  h1 is the selector of h1 tags.
  •  it selects the h1 element
  • The color is a property and red is the value of that property, a similar text-align is the property, and the value of that property is the center.

Leave a Reply

Your email address will not be published. Required fields are marked *