CSS Syntax (Rule)

 

CSS Syntax

 
Syntax usually refers to the rule that we gonna write the code, It is also considered as the grammar to write a perfect line of code.

We will discuss the syntax of CSS (Cascading Style Sheet) in the remaining part.

Syntax


The syntax of CSS involves a SELECTOR and a DECLARATION  block.












  • Selector points to the change in an HTML element that we want to style.
  • A declaration is a change that will be implemented in the HTML element.
  • Declarations block consists of one or more declarations separated through (;) Semicolon.
  • Each declaration is separated through a colon that contains a Property and a value, as shown in the image above.
  • The whole Declaration block is enclosed by Curly braces.
Example:








Example Explained

  • p is a selector in CSS (it points to the HTML element you want to style: <p>).
  • color is a property, and red is the property value
  • text-align is a property, and center is the property value





Comments

Popular posts from this blog

Basics of HTML- Learn web dev online

Block and Inline Elements of HTML

CSS - Introduction