CSS Syntax
The CSS syntax consists of a set of rules.
Basically, the rules are divided into three-part like A Selector, A Property, and A Value, for more understanding see the example below:
Important Rule of CSS Syntax
- The selector points to the HTML element want to style.
- The declaration block contains one or more declarations separated by semicolons (;), as you can see in the upper example.
- Each an every declaration includes a CSS property name and a value, separated by a colon (:).
- A CSS declaration blocks are surrounded by "curly braces" OR {...}.
Example of CSS Syntax
Syntax Example Explanation
- h1 is a name of selector
- color, font-size, and text-align are the properties
- green, 30px, and center are the values of the properties
CSS Comments
The CSS comments are used to hide OR explain the code, which means the browsers are ignored all CSS codes which are written in comments between start '/*' and end '*/'.
The Comment helps when you edit the source code at a later date.
CSS Comments Syntax
Starts with /* and end with */.
Example of CSS Comment